[LON-CAPA-dev] A lesson in globals
Guy Albertelli II
Fri, 21 Mar 2003 19:30:57 -0500 (EST)
> That's all true, but what if you want the following:
> * variable (like a tied hash) should NOT be available from outside the
> * inside the package, you want to refer to it just by its name
> Looks like "my $silly" as a package global works great for that.
No it doesn't.
> > ----- start test.pl -----
> > package globaltest;
> > use strict;
> > my $silly='a';
> > print '1'.$silly."\n";
> > print '2'.$globaltest::silly."\n";
> > package notglobaltest;
> > print '3'.$silly."\n";
> > print '4'.$globaltest::silly."\n";
> > ----- end test.pl -----
$silly is available in both pacakages.
But it's scope is limited to this file.
firstname.lastname@example.org LON-CAPA Developer 0-7-7-1-