I know that there is a statement about this in one of the perl docs, although I cannot find it now.
From perlsyn:
NOTE: The behaviour of a "my" statement modified with a statement mod
+ifier conditional or loop construct (e.g. "my $x if ...") is undefine
+d. The value of the "my" variable may be "undef", any previously ass
+igned value, or possibly anything else. Don't rely on it. Future ve
+rsions of perl might do something different from the version of perl
+you try it out on. Here be dragons.
So the following:
my $v2 = -2 if 0;
Will have undefined and probably unexp(?:exted|licible) behavior. Don't do it! Don't use a my assignment with a conditional!
Define your variable first, then set it using the conditional.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.