On Tuesday 27 April 2010 10:18:17 Michael Ludwig wrote: > A lexical variable in Perl is any variable declared with "my", regardless > of the scope, which may be file-level. Unlike globals, lexical variables > aren't directly accessible from outside the package.
Not quite correct. Consider this: $ perl -Mstrict -le ' my $x=10; our $y=20; { package hugo; print "x=$x"; # references $x outside of package hugo print "y=$y"; # references $main::y ($x,$y)=(1,2); } print "x=$x"; print "y=$y" ' x=10 y=20 x=1 y=2 $x is file-level lexical. It is visible all over the file. The embedded package hugo has no influence. Lexical variables are not bound to a package but to a lexical scope. Same with our-variables. C<our> declares the visibility of a variable in the current lexical scope. > You can read up about this issue here: > > http://perl.apache.org/docs/general/perl_reference/perl_reference.html Or for German speakers, there was a series of articles about scoping in $foo- magazin: http://foo-magazin.de/ Torsten Förtsch -- Need professional modperl support? Hire me! (http://foertsch.name) Like fantasy? http://kabatinte.net