When you have used the parentheses as grouping constructs,
persistent variables are set representing the results of each
parentheses match.
For example, the portion of the string that matched the first
group of parens is stored in $1 . The portion of the string
that matched the second group of parens is stored in $2 ,
etc.
These variables are persistent until the next match is performed.
Example:
# parser
$theVar = "I went to the store";
if ($theVar =~ /(.*) (.*) (.*) (.*)/) {
(print "Match One\n"); # Would Match
}
print "$1\n"; # I went (remember perl is greedy)
print "$2\n"; # to
print "$3 $4\n"; # the store