The problem is most likely the \1, which is not repeating the first capture as I suspect you want. You may want to do something like:
use strict; use warnings; my $matchDate = qr/(\s*\d+th\s+\w+\s*)/; while (<DATA>) { next unless /$matchDate\s+-\s+$matchDate/; print "Matched: $1 - $2\n"; } __DATA__ 5th April - 12th April
Prints:
Matched: 5th April - 12th April
In reply to Re: pattern matching
by GrandFather
in thread pattern matching
by Viki@Stag
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |