What I would do is set the default value first, then try the match. Something like this:
$match = "chiapet"; # default value if ($string =~ /foobar(...)/) { # probably want to capture something +here $match = $1; }
Or the ternary ?: operator, like this:
$match = ($string =~ /foobar(...)/) ? $1 : "chiapet";
-- Mike
--
XML::Simpler does not require XML::Parser or a SAX parser.
It does require File::Slurp.
-- grantm, perldoc XML::Simpler
In reply to Re: Regex question
by thelenm
in thread Regex question
by carric
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |