I have a bunch of matches that I need to make, and they all use the same code, except for the file name to read and the regular expression itself. So I want to turn the match into a procedure that just takes the file name and regular expression as a string. When I use a variable to try to match, special fixed variables cease to be set.
$line =~ /(\d+)\s(\d+)\s/;
This code sets $ 1 and $ 2 correctly, but the following leaves them undefined:
$regexp = "/(\d+)\s(\d+)\s/";
$line =~ /$regexp/;
Any ideas how I can get around this?
Thanks Jared
Jared source
share