perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Förtsch <>
Subject Re: Getting a / when regex should produce nothing
Date Tue, 27 Apr 2010 09:25:33 GMT
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
  print "x=$x";
  print "y=$y"

$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:

Or for German speakers, there was a series of articles about scoping in $foo-

Torsten Förtsch

Need professional modperl support? Hire me! (

Like fantasy?

View raw message