Hi all ,

 

Can someone help me on this....

 

________________________________

From: Sureshkumar M (HCL Financial Services) 
Sent: Saturday, November 29, 2008 4:21 PM
To: 'David Schmidt'
Cc: beginners@perl.org
Subject: RE: date format search insdie the files

 

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); beginners@perl.org
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

Reply via email to