in reply to A 'print' at one spot changes a value at another
Variable "$sep" is not available at (eval 9) line 1 (#1)
(W closure) During compilation, an inner named subroutine or eval is
attempting to capture an outer lexical that is not currently available.
This can happen for one of two reasons. First, the outer lexical may be
declared in an outer anonymous subroutine that has not yet been created.
(Remember that named subs are created at compile time, while anonymous
subs are created at run-time.) For example,
sub { my $a; sub f { $a } }
At the time that f is created, it can't capture the current value of $a,
since the anonymous subroutine hasn't been created yet. Conversely,
the following won't give a warning since the anonymous subroutine has by
now been created and is live:
sub { my $a; eval 'sub f { $a }' }->();
The second situation is caused by an eval accessing a variable that has
gone out of scope, for example,
sub f {
my $a;
sub { eval '$a' }
}
f()->();
Here, when the '$a' in the eval is being compiled, f() is not currently being
executed, so its $a is not available for capture.
Use of uninitialized value $sep in concatenation (.) or string at (eval 9) line
1 (#2)
(W uninitialized) An undefined value was used as if it were already
... snip ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A 'print' at one spot changes a value at another
by tlm (Prior) on Aug 15, 2005 at 08:32 UTC | |
by dave_the_m (Monsignor) on Aug 15, 2005 at 09:36 UTC | |
by ysth (Canon) on Aug 15, 2005 at 13:17 UTC | |
by dave_the_m (Monsignor) on Aug 15, 2005 at 13:31 UTC | |
by ysth (Canon) on Aug 15, 2005 at 13:38 UTC |