Hello Jos, "Jos I. Boumans" wrote: > > let's see if i can shed some light on this. > > your statement: > print("Defined: <<$z>>\n") if defined(my $z="x"); > > this will be evaluated like this if i'm not mistaken: > ( print("Defined: <<$z>>\n") ) && defined(my $z="x"); > > or a simplistic version: > (print $z) && (my $z = 'bar'); I was always under impression (and under a rather strong one :) that this evaluates the other way round: (my $z = 'bar') && (print $z); You first check the control expression and then evaluate the main expression (if the control expression succeeds). IMHO, It doesn't make sense otherwise. That's why I expected it to work... but perhaps I was wrong (see below). > try and 'use strict' and you'll see where the problem lies. You are right, enabling strict mode produces complaint about unqualified global $z. Hmm, now that's becoming even more weird... > what's happening is that the parser is a bit unhappy. I also thought this is a parser thing, but I tried with 3 different Perl versions with exactly the same result. > first you use a variable, then you declare it. see, the parser works left to > right, I don't think a simple statements with modifiers like 'if EXPR' are being parsed left to right. Not sure about Perl parser, but both Yacc-style (bottom-up) and recursive descent parsers would try to consume the whole statement with modifier to match as a production... > so it will see your $z before you declare it and tell you so under use > strict. > > runtime things work right to left, so that's why > $z = 'bar; (print $z) if $z; > works just fine. > > hth, > > Jos Boumans 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]