A
Andre Majorel
Is there a way to override the value returned by a capture so
that $1 is set not to the characters matched by the parentheses
but some arbitrary string or number ? I'm thinking of something
like this :
$ perl -e '
sub what ($)
{
if ($_[0] =~ /((?"integer"\d+)|(?"word"\w+))/) # Fictitious syntax
{
print "the string \"$_[0]\" matched a \"$1\"\n";
}
}
what ("123");
what ("abc123");
'
the string "123" matched a "number"
the string "abc123" matched a "word"
that $1 is set not to the characters matched by the parentheses
but some arbitrary string or number ? I'm thinking of something
like this :
$ perl -e '
sub what ($)
{
if ($_[0] =~ /((?"integer"\d+)|(?"word"\w+))/) # Fictitious syntax
{
print "the string \"$_[0]\" matched a \"$1\"\n";
}
}
what ("123");
what ("abc123");
'
the string "123" matched a "number"
the string "abc123" matched a "word"