on Tue, 21 May 2002 23:24:09 GMT, [EMAIL PROTECTED] (Alan Hogue)
wrote:
> my $foo =~ /Foo \d{4} at \S+, \w{2}/;
>
> But this only returns a true or false value, not what has been
> matched, so I can't just directly assign what has been matched to
> another variable, or can I? What am I missing?
First you have to put the parts you want to extract from the regex
between parentheses, then either use ('$foo' already should contain the
string you want to search):
my ($a, $b, $c) = $foo =~ /Foo (\d{4} at (\S+), (\w{2})/;
or
my ($a, $b, $c);
if ($foo =~ /Foo (\d{4} at (\S+), (\w{2})/) {
$a = $1; $b = $2; $c = $3;
} else {
# No match
}
--
felix
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]