Mihir Kamdar wrote: > thanks all.....and how will be the code like for my requirement if i use > DateTime...
I truly thought that you might have attempted to try the complete cut/paste-able program I wrote and made slight changes to fit your "requirement". Even if not, at least testing it would have been nice. The code I gave you earlier is put verbatim below, with additional functions. #!/usr/bin/perl use strict; use warnings; use DateTime::Format::Strptime; my $EXTRACTION_LAYOUT = '@16 A1 @40 A9'; VOUCHER_RECORD: while ( my $record = <DATA> ) { my ( $important_num, $date_string ) = unpack $EXTRACTION_LAYOUT, $record; next VOUCHER_RECORD if $important_num != 2; my $static_date = DateTime->new( year => 2009, month => 3, day => 31 ); # turn the extracted date string into a DateTime object my $date_formatter = new DateTime::Format::Strptime( pattern => '%d-%b-%y' ); my $voucher_date = $date_formatter->parse_datetime($date_string); # compare the DateTime compiled dates if ( DateTime->compare( $static_date, $voucher_date )) { # - put your record/store functions code in this space. # - depending on what you want to do, these comments # are within the code block that ensures that your 2nd # field is equal to '2', and that the 5th field is less # than Mar 31, 2009 # - depending on how you want to "store" the information, # I might suggest http://perldoc.perl.org/Storable.html } } __END__ Please at least copy/paste my code and try it if you've been able to install DateTime. Use the example in my earlier post, as it also contains the data which is properly formatted. To be bluntly honest, I'm quite proud of my tiny code snip. I had to research/try the patterns for DateTime to get them right, and counted with my finger to position the layout properly. ...I am completely flabbergasted with your response. See kids, the post I am responding to is not proper list etiquette! Steve
smime.p7s
Description: S/MIME Cryptographic Signature