Hi David,
Thanks for the reply, but still I am not able to get expected
output from this.
Pls help me how to get this.
(C)/tmp/d$ cat a1
115-06-1979
10-11-81
20-NOV-2008
05-07-1981
welcome
20-03-20009
15-10-2008
(C)/tmp/d$ cat 1
#/usr/bin/perl
use strict;
use warnings;
open(DATA,"a1")||die"Unable to open the file";
while(<DATA>)
{
#if($_=~/\d\d\D(\d\d|\[a-zA-Z]{3})\D\d\d/)
if(/(\d{2}-(\d{2})|(\w{3})-\d{1,4})/)
{
#print $_;
print ;
}
}
close(DATA);
exit 0;
(C)/tmp/d$ perl 1
115-06-1979
10-11-81
20-NOV-2008
05-07-1981
20-03-20009
15-10-2008
(C)/tmp/d$
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
David Schmidt
Sent: Saturday, November 29, 2008 3:12 PM
To: Sureshkumar M (HCL Financial Services); [email protected]
Subject: Re: date format search insdie the files
You missed some parentheses
#!/usr/bin/perl
use strict;
use warnings;
open(DATA, '<', "data") || die"Unable to open the file";
while(<DATA>) {
#if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/) {
if(/(\d{2}-(\d{2})|(\w{3})-\d{1,4})/) {
print;
}
}
close(DATA);
exit 0;
On Sat, Nov 29, 2008 at 10:11 AM, Sureshkumar M (HCL Financial
Services) <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I try to search the string which has the date format inside
> the file,
>
> But i am not able to get the desired files. Pls help me on this..
>
>
>
>
>
>
>
> C)/tmp/sms/perl$ cat a1
>
>
>
> 115-06-1979
>
> 10-11-81
>
> 20-NOV-2008
>
> 05-07-1981
>
> welcome
>
> 15-10-2008
>
> 12-03-20009
>
>
>
>
>
> (C)/tmp/sms/perl$ cat 1
>
>
>
> #/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;
>
> (C)/tmp/sms/perl$
>
>
>
>
>
>
>
> Output should be :
>
>
>
> 10-11-81
>
> 20-NOV-2008
>
> 05-07-1981
>
> 15-10-2008
>
>
>
>
>
>
>
>
>
>
>
>
--
David Schmidt | http://www.fm5.at
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.
-----------------------------------------------------------------------------------------------------------------------