The stupid question is the question not asked | |
PerlMonks |
Re: Re: Re: Regex questionby Koosemose (Pilgrim) |
on Mar 20, 2004 at 16:30 UTC ( [id://338311]=note: print w/replies, xml ) | Need Help?? |
To reiterate NetWallah's point, you won't get into the loop if the regex doesn't match, meaning that if you do get into the loop, there will be something in $1, so any code to set a default value won't be called. If you have to run what is presently in the if block regardless of rather or not the match was successful, then it probably shouldn't be an if block. You may wish to use something along the lines of thelenm's second snippet instead, something like this:
note the lack of the if block...
Just Another Perl Alchemist
In Section
Seekers of Perl Wisdom
|
|