Hi!

Isn't this weird?

#!/usr/bin/perl -w
print("Defined: <<$z>>\n") if defined(my $z="x");
print "Assigned: <<$z>>\n";

Produces:

Defined: <<>>
Assigned: <<x>>

So it looks like $z *is* defined but *not* assigned until we are out of
the 'if' statement. Is it a bug? My understanding it should either stay
undefined or defined *and* assigned at the same moment, am I missing
something?

There's nothing helpful in the documentation, the only short note in
perlvar admits that whatever more or less detailed description of my()
scope issues it has for complex statements -- does *not* apply to simple
ones (like the above example). However, description of the scoping
within simple statements is nowhere to be found :(.

-w switch produces complaints about '"main::z" used only once' but this
is not very helpful, I'd like to know *why* it appears to not being
properly initialized...

Cheers,
Ivan

-- 
Dr Ivan Adzhubei                     Tel +7 (095) 777 8913
GlaxoSmithKline                      Fax +7 (095) 777 8901
61 Novocheremushkinskaya str
117418 Moscow, Russia

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to