Dave Mitchell <davem@fdgroup.com> wrote:
:I'd expect the following to output 12,12; in fact it outputs 12,11
:
: #!/usr/bin/perl -wl
:
: $x = 1;
: my $x = 2;
:
: { my $x = $x+10; print $x }
: { our $x = $x+10; print $x }
:
:Does anyone else agree that 'our' should behave the same as 'my'
:as regards scope before the variable has been introduced?
I'm not sure that I'd have used those words, but yes I think that
looks like a bug: in C< our $x = $x+10 > the value picked up should
be the $x currently in scope, which in this case would be the
lexical.
Hugo
Thread Previous
|
Thread Next