LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-07-2010, 09:44 AM   #1
Harris Jayaraj123
LQ Newbie
 
Registered: Apr 2010
Posts: 1

Rep: Reputation: 0
Perl : Get Maxdate from the file


Hi All,

I have a input file like below :
-------------------------------------------------
949890;01-4477138;20101208;7003907933;0
1352305;01-32175;20101225;7005373440;0
0771586;03-975357;20091206;7004353176;0
1868963;06-26112;20101001;7004927161;0
1877828;08-300381;20101008;7004591372;0
0158942;08-371741;20100512;7011021111;0
1889407;03-282266;20101114;7025777256;0
1426078;08-53175593;20100204;7004814000;0
1805938;03-274032;20110823;7006722399;0
0993741;02-55239;20090516;7004863481;0
1981600;40-302572;20110301;7031323637;0
---------------------------------------------------
The third field in this file is date in YYYYMMDD format.

I need to get the max date(20110823) from this file and store it in a variable for doing dome calculataions.
How can i get the max date from this file using perl script ??

Thanks in advance

Regards,
Harris
 
Old 04-07-2010, 10:24 AM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by Harris Jayaraj123 View Post
Hi All,

I have a input file like below :
-------------------------------------------------
949890;01-4477138;20101208;7003907933;0
1352305;01-32175;20101225;7005373440;0
0771586;03-975357;20091206;7004353176;0
1868963;06-26112;20101001;7004927161;0
1877828;08-300381;20101008;7004591372;0
0158942;08-371741;20100512;7011021111;0
1889407;03-282266;20101114;7025777256;0
1426078;08-53175593;20100204;7004814000;0
1805938;03-274032;20110823;7006722399;0
0993741;02-55239;20090516;7004863481;0
1981600;40-302572;20110301;7031323637;0
---------------------------------------------------
The third field in this file is date in YYYYMMDD format.

I need to get the max date(20110823) from this file and store it in a variable for doing dome calculataions.
How can i get the max date from this file using perl script ??

Thanks in advance

Regards,
Harris
Visit search.cpan.org and pick whatever date/time module from there - is a whole bunch; one is very good, with nice self-explanatory interface.

But, actually, date in YYYYMMDD format is lexically sortable

(see
perlfunc -f sort
).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl File Handler - will autoflush clear the memory the file requires? doug23 Programming 3 08-20-2009 12:32 AM
How to modify a field in few lines in a file and save the new file - in Perl rounak94 Programming 1 10-02-2008 07:43 PM
Perl file conversion results in a truncated file kshaffer Programming 0 01-31-2005 02:31 PM
cgi perl : I cant get perl to append my html file... the_y_man Programming 3 03-22-2004 05:07 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration