=head2 If we've had a regular expression with grouping, we need to show the matches we made there too. Unless we count the number of matching parens, which could get odd if there was a match looking for '(' and ')', we run a simple counter and check if the match variable exists. If it does, we print it out. If no parenthesis are used, $match_results holds our match. =cut {eval "\@matches = (\$user_text =~ $regex); \$match_results .= \$&;"; $match_results .= "\n"; $match_results .= " Variables:\n"if defined($matches[$i]); for (my $i = 1; $i <= @matches; $i++) { my $found = $matches[$i - 1]; $match_results .= " \$$i:$found \n" if defined($matches[$i]); } } # end eval block } # end if substr eq 'm'