Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

proper usage of CGI.pm

Status
Not open for further replies.

WintersMystic

Programmer
Aug 8, 2001
39
0
0
US
ok, some people tell me that this is the proper way

use strict;

use CGI;

use CGI qw:)standard);

$q = new CGI;

and others tell me i dont need

use CGI;

when using

use CGI qw:)standard);

which is right?? :)
 
Realistically you only need one or the other. If you don't specify a tag, such as ":standard", then all functions will get loaded with the package. However, when you specify a distinct set of functions using a tag, then only those functions get loaded.

The reasoning behind this is to save the the interpreter form needlessly compiling functions that aren't required.

If you have a high profile site, then it will make a difference as it will mean each process is grabbing memory it doesn't need.

HTH,
barbie.
Leader of Birmingham Perl Mongers
 
Here is a good link to check out:


From what I have experienced, calling the CGI.pm with just:

use CGI;

will not import any of it's functions into your MAIN namespace. SO if you said:

print header();

And this is gonna really hurt... if you are using the object oriented interface ( $q = new CGI; <--this was in your post) then you don't need to worry about importing the functions at all! So for you, using the object oriented style, you could just say: use CGI;
and you would be fine.

Hope this helps,

--Jim

you would get an error. However:

print CGI::header();

would work as desired. If you check out the link, above, it will describe the different &quot;sets&quot; of functions you can import into your MAIN namespace in order to balance efficient execution with elegant scripting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top