By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,178 Members | 971 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,178 IT Pros & Developers. It's quick & easy.

Only fetch date from array.

P: 41
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
Oct 27 '09 #1
Share this Question
Share on Google+
1 Reply


Expert
P: 70
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.
Oct 27 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.