in reply to Re: Is this a bug in Perl scope?
in thread Is this a bug in Perl scope?
package one;
use strict;
use warnings;
my $var = 1;
sub tell {
print "$var\n";
}
package two;
use strict;
use warnings;
my $var = 5;
sub tell {
print "$var\n";
}
package main;
use strict;
use warnings;
my $var = '20';
sub tell {
print "$var\n";
}
one::tell();
two::tell();
main::tell();
Produces the following output:
"my" variable $var masks earlier declaration in same scope at test.pl line 12. "my" variable $var masks earlier declaration in same scope at test.pl line 20. 1 5 20
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Is this a bug in Perl scope?
by Corion (Patriarch) on Jul 22, 2012 at 14:05 UTC | |
by tobyink (Canon) on Jul 22, 2012 at 19:15 UTC | |
by AnomalousMonk (Archbishop) on Jul 22, 2012 at 22:59 UTC | |
|
OT Re^3: Is this a bug in Perl scope?
by ww (Archbishop) on Jul 23, 2012 at 00:57 UTC |