Phoenix.pm: Perl internals questions

Shay Harding sharding at ccbill.com
Mon May 10 16:47:10 CDT 1999


Just wondering the following:

Which is faster at execution, uses less memory, best overall in terms of
performance:


use CGI qw(:standard);
print header
print start_html
etc


or


use CGI;
$cgi = new CGI;

print $cgi->header
print $cgi->start_html
etc;

??

Using the OO implementation seems to be the best choice. Just wondering if any one knows which is better
overall and why?



Since there is a global package 'main' can one script access another's
variables if they know what they are. I haven't tried this yet and am just
wondering if anyone knows.

Or is it the case that each script has it's own global package 'main'?




Last question...


Can you create namespaces dynamically like so:


$var = "A";

sub create_namespace($){
  package $_[0];             # or maybe eval ($string = "package $_[0]");
}


sub write_to_package($$$){
  my ($package,$var_name,$var_value) = @_;
  %$package::$var_name = $var_value;
}



Just a few questions I've been thinking of.


Shay




More information about the Phoenix-pm mailing list