CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
CGI.pm...What's better

 



yapp
User

Nov 13, 2001, 3:49 AM

Post #1 of 6 (1779 views)
CGI.pm...What's better Can't Post

Hello.

I'm wondering (maybe it doesn't matter anyway),
but does it matter how you use the CGI module??

I always import

Code
use CGI qw(:cgi);

. See in the source of CGI.pm what get's imported...

That means I never use the object orientated method of CGI.pm...

Does that matter?

Yet an Other Perl Programmer

_________________________________
Find out more about programming
http://www.cool-programming.f2s.com


thodi
stranger

Nov 13, 2001, 3:57 AM

Post #2 of 6 (1777 views)
Re: CGI.pm...What's better [In reply to] Can't Post

I think what matters is that you get the job done -- if you are comfortable and satisfied with the way you do it, why change anything?

I myself like object orientation, but that's probably because 'grew up' with it while studying.



fashimpaur
User / Moderator

Nov 13, 2001, 3:58 AM

Post #3 of 6 (1776 views)
Re: CGI.pm...What's better [In reply to] Can't Post

Well, yes and no. How's that for waffling on the subject? I am a big fan of object oriented reuseable code. Not cut and paste. Truly reuseable. Since CGI.pm was written for object oriented use, I have made a concerted effort to use it in this fashion. I make a new CGI object, call it's methods, set and get it's attributes. I do this not because someone tells me to, but rather because it is just a good practice and promotes OOPerl.

Do you have to use it? No. Generally, programmers only do what is required to get the project done, and then move on. I find this can mean that I am forever cutting and pasting code and try to avoid it like the plague. You have to do whatever you are comfortable with. Try to keep improving your skills and don't be complacent with where you are at. You will go much farther in the future.

HTH,

Dennis

$a="c323745335d3221214b364d545a362532582521254c3640504c37292f493759214b3635554c3040606a0",print unpack"u*",pack "h*",$a,"\n\n"


yapp
User

Nov 13, 2001, 4:02 AM

Post #4 of 6 (1775 views)
Re: CGI.pm...What's better [In reply to] Can't Post

Thanks for the fast reply

Off course that's what matters. Sometimes It also matters HOW you get the job done. That's what I've grown up with. (some don't care about that factor, making large bad buggy programs)

I don't consider changing my program structure.
However, I am just interested in the differences.

I also grew up with OOP. In Java (at school) or Visual Basic (at home) I ALWAYS use Objects (in VB6 that's very easy)... In perl I never tried making objects (only using them) It seams so weird, strange and difficult in Perl...

Yet an Other Perl Programmer

_________________________________
Find out more about programming
http://www.cool-programming.f2s.com


yapp
User

Nov 13, 2001, 4:07 AM

Post #5 of 6 (1775 views)
Re: CGI.pm...What's better [In reply to] Can't Post

For CGI.pm I don't see a reason it use objects..
a. You don't make two CGI objects, duh!
b. There is no copy-paste factor. The module can just be imported.
c. That also applies to all my other modules.
Any CGI, Test::Input, and print() to the console module doesn't need OOP.

A IO::Socket, Tk and lots of other things are almost impossible without OOPerl (like the funny word)...

However, I still don't understand something about working with OOP in perl. What can I do, and how. I've seen something with a hash, and bless() but I didn't understand it.

Yet an Other Perl Programmer

_________________________________
Find out more about programming
http://www.cool-programming.f2s.com


thodi
stranger

Nov 13, 2001, 6:09 AM

Post #6 of 6 (1772 views)
Re: CGI.pm...What's better [In reply to] Can't Post

There's some pretty good documentation supplied with Perl, read perlboot, perltoot, perltootc and perlbot. If you've used OO before, you will have no problem understanding it. The bottom line is: (1) A class is a package. (2) An object is a reference (most people use hash refs, but that's just because it's practical, not beacuse it has to be) that is 'blessed' -- which means it knows what class it belongs to.


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives