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::<globalvarname> (same as $::<globalvarname> rather than some other $<package>::<globalvarname>. 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 = (one => 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)]); _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
