Thanks a lot for your help,,
Can you explain me this part how it's works?
(?:\d{2}|\w{3})
?: what this will do?
And also, the output is like below
(C)/tmp/d$ perl 1
10-11-81
20-NOV-2008
05-07-1981
15-110-2008 this should not come as this as 3 digit month.
(C)/tmp/d$
Program:
(C)/tmp/d$ cat 1
#/usr/bin/perl
use strict;
open(DATA,"<a1")||die"Unable to open the file";
while(<DATA>)
{
print if /\b\d{2}\b-(\d{2}|\w{3})-\b\d{2,4}\b/;
}
close(DATA);
exit 0;
(C)/tmp/d$
-----Original Message-----
From: Dr.Ruud [mailto:[EMAIL PROTECTED]
Sent: Saturday, November 29, 2008 5:30 PM
To: [email protected]
Subject: Re: date format search insdie the files
"Sureshkumar M (HCL Financial Services)" schreef:
> #/usr/bin/perl
> open(DATA,"a1")||die"Unable to open the file";
> while(<DATA>)
> {
> if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/)
> {
> print $_;
> }
> }
> close(DATA);
> exit 0;
#!/usr/bin/perl
use strict;
use warnings;
my $in_name = "data.in";
{ open my $in_fh, "<", $in_name
or die "Error with '$in_name': $!";
while ( <$in_fh> ) {
print if /\b\d{2}-(?:\d{2}|\w{3})-\d{1,4}/;
}
}
__END__
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended
for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates.
Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the
opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. Before opening any mail and
attachments please check them for viruses and defect.
-----------------------------------------------------------------------------------------------------------------------
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/