in reply to -w, strict, and Tk...
This error pops up occasionally, usually for the right reason but occasionally, (such as where you declare a variable in your script but only acess the variable from within an eval), quite incorrectly.
The solution is usually simple:
By adding the anonymous block with the (useless but for its side effect) lexical declaration and assignment of $x, the compiler has now seen the variable twice and the warning goes away, but with little cost or impact on your script. (In fact it wouldnt suprise me in the least if the compiler optimizes it away, _after_ the lexical analysis phase)use warnings; use strict; our $x; eval (' $x=1; print $x; '); #Generates a warning that $x is only used once.. Incorrectly. # {my $work_around=$x} # Uncomment to make the error go away.
If you had to make a bunch of these disappear then maybe
Would be the neatest way to resolve them all in one workaround.{ my @work_around=($x,$y,$z); }
Yves / DeMerphq
--
This space for rent.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: -w, strict, and Tk...
by greenFox (Vicar) on Mar 20, 2002 at 13:58 UTC | |
by RMGir (Prior) on Mar 20, 2002 at 14:07 UTC |