note
BrowserUk
<p>I think I understand what you/they mean, but the empirical evidence says different.
<code>
p:\test>perl -Mstrict -lwe"my $foo=1 if 'X' =~ /Y/; print 'Result is: ', $foo; "
Use of uninitialized value in print at -e line 1.
Result is:
p:\test>perl -Mstrict -lwe"my $fob=1 if 'X' =~ /Y/; print 'Result is: ', $foo; "
Global symbol "$foo" requires explicit package name at -e line 1.
Execution of -e aborted due to compilation errors.
</code>
<p>In both examples, $foo in the print statement has never been assigned a value.
<p>In the first example, the compiler has seen the declaration and so only it's definedness is a problem and we get the "Use of uninitialized value" warning.
<p>In the second case, it is not only undefined, it doesn't exists and so we get the "Global symbol "$foo" requires explicit package name" error.
<p>It clearly indicates that although the [if] condition is false and the assignment is never performed, the [my] declaration has been see and acted upon.
<p>This is true with 5.6.1 and 5.8.1. Maybe the documentation is out of date?
<div class="pmsig"><div class="pmsig-171588">
<hr />
<font size=1 >
<div>Examine what is said, not who speaks.</div>
"Efficiency is intelligent laziness." -David Dunham<br />
"Think for yourself!" - [Abigail-II|Abigail] <br />
[http://news.bbc.co.uk/1/hi/technology/3181108.stm|Hooray!]<br />
</p></font>
</div></div>
318130
318248