in reply to Re: difference between 'if (condition) { expression;}' and 'expression if (condition)'
in thread difference between 'if (condition) { expression;}' and 'expression if (condition)'

Careful with my $var if $condition. From perlsyn:

NOTE: The behaviour of a "my" statement modified with a statement modifier conditional or loop construct (e.g. "my $x if ...") is undefined. The value of the "my" variable may be "undef", any previously assigned value, or possibly anything else. Don't rely on it. Future versions of perl might do something different from the version of perl you try it out on. Here be dragons.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

  • Comment on Re^2: difference between 'if (condition) { expression;}' and 'expression if (condition)'
  • Download Code

Replies are listed 'Best First'.
Re^3: difference between 'if (condition) { expression;}' and 'expression if (condition)'
by ranjan_jajodia (Monk) on Mar 22, 2006 at 14:40 UTC
    Thanks xdg. I won't use. I saw something similar in an existing code and I was surprised that it works. Hence I decided to prod a bit.
    Regards,
    Ranjan