Connecting Tech Pros Worldwide Forums | Help | Site Map

Only fetch date from array.

Member
 
Join Date: Mar 2008
Posts: 32
#1: 4 Weeks Ago
Hi,

I have a flat file like:

106|4 |ABC|0000000280| 919886046726| 253436| TP001| 1| 4200| 998607230300| 12345630864|BUNDLE| ACE1| | | | 00e142daaf20b965| 99| |13|01|NA|2009-10-20 13:00:05| 110| 110| | 521000|3|N| | PQRS| N| CHARGE| 110| PER_TIME_02| 240| 59992000| 0| |


I have already split the "|" delimetere & store into an array.

My Question is i want to fetch the date format ( "2009-10-20" ) from "2009-10-20 13:00:05" elements in array & store into that array.

I have made a script like below:

#!/usr/bin/perl

print ("Read actual file\n");

open (FILE,"actual") || die("Can't Open actual");

foreach $data(<FILE>)
{
@data = split(/\|/, $data);
}
close(FILE);

print "@data";


So i need "2009-10-20" instead of "2009-10-20 13:00:05" in @data.

Plz, somebody help.

Thanks
DKS

Newbie
 
Join Date: Sep 2009
Posts: 15
#2: 4 Weeks Ago

re: Only fetch date from array.


Once you have '2009-10-20 13:00:05' in a string,
just split the string on whitespace and grab the
1st element of the returned list.
Reply