thanks bill ... i get it ... I guess i will make everyone use "use strict" ...
One more thing:
i came across a .cgi file from my pool of .cgi files which has foll. statement:
do global.pl
My question: does this run the entire code in "global.pl" (unlike use and require)??
I saw the output and i believe it does ... i know wht "use" and "require" does ... but i thght "do" was also for loading a module into memory ... was i wrong??
Regards,
Ukh
$Bill Luebkert <[EMAIL PROTECTED]> wrote:
ukhas jean wrote:
> Hello,
>
> I am having many .cgi files for an intranet site ... The problem is ...
> many developers have used repetitive variable names in different .cgi
> files with a varying/global scope ... eg. %diff_levels is a hash defined
> in many .cgi files ...
>
> My question: Are .cgi files similar to .pm files with regards to giving
> a fully qualified name to a var.?? eg. $package_name::var
> Can I do the above in a .cgi file as well??
Without being in a package, all globals are $main::(same as
$::rather than some other $ :: .
Having the same name in different .cgi/.pl files is irrelevant unless you
either combine or include them into each other. Then you could end up
with duplicate names like your $diff_levels ($main::diff_levels) and have
to deal with it.
What you should be doing is getting them to avoid globals as much as
possible and using 'use strict;' and 'use warnings;' to start each file.
There's nothing to stop you from adding a package directive at the start
of each file that you plan on combining (you could use the base filename
as the package name).
package foo;
our %diff_levels = ( 1);
print Data::Dumper->Dump([\%diff_levels], [qw(\%diff_levels)]);
package bar;
our %diff_levels = (two => 2);
print Data::Dumper->Dump([\%diff_levels], [qw(\%diff_levels)]);
# go after a specific package :
print Data::Dumper->Dump([\%foo::diff_levels], [qw(\%foo::diff_levels)]);
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail.
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
