Can someone tell me please why in the following program $1 is not defined ? I thought that every group (every pair of parentheses) is going to $1, $2, $3 and so on.
Where am I wrong ?
Which pairs of parentheses are going to $1, $2, $3, ... ?
Thanks in advance !!
$_ = "a bc";
if (/(bc)?/) {
print "\$1 = [$1]\n" if (defined $1);
} else {
print "No match !";
};
Where am I wrong ?
Which pairs of parentheses are going to $1, $2, $3, ... ?
Thanks in advance !!
$_ = "a bc";
if (/(bc)?/) {
print "\$1 = [$1]\n" if (defined $1);
} else {
print "No match !";
};