Dermot wrote:
2008/11/22 Sureshkumar M (HCL Financial Services) <[EMAIL PROTECTED]>:
#!/usr/bin/perl
# Always use these, particularly when things aren't working as expected.
use strict;
use warnings;
open(DATA,"i")||die "Unable to open the file";
while(<DATA>)
{
if($_=~/(\d{2})([\W])\1\2\1]/)
I could be wrong but I don't think \w will not match a hypen "-" so
the test will fail.
\w won't match '-', but \W will.
This works for me:
if ($_=~/\d{1,2}-(\d{2}|\w{3})-\d+/)
The OP wanted to match only two digit day values. \w will also match
digits so that will match a three digit month number. The OP didn't
want to match year values with one or five digits but that will match them.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/