Hello Bob, > I think the answer can be found in the following statement in the persub > manpage > under the heading "Private Variables via (my)": Yes, I read this (sorry for typing error, perlsub should be cited in my initial message instead of perlvar). Unfortunately, the following passage you cited is incorrect. Or let us say, things are not that simple in real life. For instance, my() declarations inside control parts of loop statements do instantiate my() variables withing controlled blocks, e.g. *before* the end of the current statement: foreach my $i (@list) { print $i; } works as expected. However, it is probably a terminology issue, since loops and conditionals aren't statements at all, rather blocks (even though they are listed under 'Compound statements' title in perlsyn)... I assume perlvar passage you cited actually refer only to *simple* statements, not loops and conditionals. Where I was obviously wrong is that I also assumed that for simple statements with modifiers my() works the same as for compound statements. > The declared variable is not introduced (is not visible) until after > the current statement. Thus, > > my $x = $x; > > can be used to initialize a new $x with the value of the old $x, and > the expression > > my $x = 123 and $x == 123 > > is false unless the old $x happened to have the value "123". > > So the $z being printed in the first line of your example is the global $z, > not the lexical (my $z). > Adding "use strict;" to the program will highight this fact by complaining > about using the > global $z on the first line. That's right, strict produces exactly the kind of complaint you suggested. Things are looking a bit more clear for me now. Thanks for help! 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]