Never do
my $var = ... if ...;,
my $var = ... unless ...;,
my $var = ... for ...;,
my $var = ... foreach ...; or
my $var = ... while ...;
Split them into two statements, like
my $var; $var = ... if ...;.
Update: Well, this is bothering me. I can't remember why, and I can't find an example where the above fails.
Update: diotalevi, which I believe has a knowledge of Perl guts, mentions: "my() has a runtime effect. You *always* (unless you're doing something freakish) want that to happen. The my $var STATEMENT-MODIFIER allows the runtime part of my() to potentially not happen." In other words, it sounds like doing any of the above leaves perl in an unstable state.
In reply to Re^3: getting a regex to return an array of matches?
by ikegami
in thread getting a regex to return an array of matches?
by rmexico
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |