carric has asked for the wisdom of the Perl Monks concerning the following question:
Tryin to noodle this out and looking for a some help. Basically, I want to set a value to the match for a regex, UNLESS it didnt' match, and then I want to set a default value for this var.. e.g.</p.
...snip... if( $string =~ /foobar/ ) { $match = $1 unless undef then $match = "chiapet"; ]
Now, obviously this silly code doesn't work, but how would I go about acheieving this? Thanks a lot in advance.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex question
by thelenm (Vicar) on Mar 19, 2004 at 22:07 UTC | |
Re: Regex question
by Happy-the-monk (Canon) on Mar 19, 2004 at 22:09 UTC | |
by carric (Beadle) on Mar 19, 2004 at 22:37 UTC | |
by Happy-the-monk (Canon) on Mar 19, 2004 at 23:34 UTC | |
Re: Regex question
by NetWallah (Canon) on Mar 19, 2004 at 22:08 UTC | |
by carric (Beadle) on Mar 19, 2004 at 22:39 UTC | |
by Koosemose (Pilgrim) on Mar 20, 2004 at 16:30 UTC | |
Re: Regex question
by Somni (Friar) on Mar 22, 2004 at 13:04 UTC |