in reply to pattern matching
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pattern matching
by Viki@Stag (Sexton) on Nov 22, 2007 at 12:49 UTC |