in reply to Re^2: getting a regex to return an array of matches?
in thread getting a regex to return an array of matches?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: getting a regex to return an array of matches?
by rmexico (Novice) on Feb 14, 2006 at 18:52 UTC | |
by ikegami (Patriarch) on Feb 14, 2006 at 19:03 UTC | |
by PodMaster (Abbot) on Feb 15, 2006 at 05:13 UTC |