Hi all, I tried using the below codes provided but i got an error saying "Can't locate Date/Manip.pm in @INC...etc". I reckon that the Date::Manip do not exist in my library. Any other alternatives for my problem below?
Regards, ~ HENRY WONG ~ > Henry Wong wrote: > > > Hi all, > > > > I am wondering if you guys can help me out here: > > I have a log file containing information like this: > > > > THU DEC 6 14:55:00 2001 111 222 333 444 > > FRI DEC 7 01:00:00 2001 555 666 777 888 > > SAT DEC 8 13:00:00 2001 xxx xxx xxx xxx > > SUN DEC 9 04:00:00 2001 xxx xxx xxx xxx > > MON DEC 10 12:00:00 2001 xxx xxx xxx xxx > > TUE DEC 11 09:00:00 2001 xxx xxx xxx xxx > > : > > : > > : > > & so on... > > > > Having the above log file with the first column containing the usual TIME, > > following by 4 columns of numerical data, I am thinking of having this > > program asking the user to input his/her desired starting date & ending > > date, and thus thereby extracting all the relevant 4 column datas > > corresponding to the above dates. > > > > What i'm trying to say is, lets say the user inputs START DATE to be THU > > DEC 6, and END DATE to be MON DEC 10. So my code will then extract all > > relevant data corresponding to THU DEC 6 (which is 111, 222, 333, 444) up > > till MON DEC 10. That means the code would've extracted all 5 rows of data > > with their corresponding 4 xxx columns (from start date to end date), and > > then putting it into a file. > > > > Is this possible? How do I code the above concept? Do advise me, thanks in > > advance! > > > > yes. with Date::Manip, it can be easily done: > > #!/usr/bin/perl -w > use strict; > use Date::Manip; > > my @db; > open(LOG,'data.log') || die $!; > while(<LOG>){ > chomp; > my @fields = split(/\s+/); > my $date = ParseDate(join(' ',@fields[0..4])); > my $seconds = Date_SecsSince1970(UnixDate($date,'%m'),UnixDate($date,'%d'), > UnixDate($date,'%Y'),UnixDate($date,'%H'), > UnixDate($date,'%M'),UnixDate($date,'%S')); > push(@db,[$seconds,@fields[5..$#fields]]); > } > close(LOG); > > while(1){ > > my @dates = (undef,undef); > > for(1..2){ > > print "Enter date: "; > my $d = <STDIN>; > > exit if($d =~ /^exit/i); > > my $t = ParseDate($d); > > my $index = 0; > $index = 1 if(defined $dates[0]); > > $dates[$index] = Date_SecsSince1970(UnixDate($t,'%m'),UnixDate($t,'%d'), > UnixDate($t,'%Y'),UnixDate($t,'%H'), > UnixDate($t,'%M'),UnixDate($t,'%S')); > } > > foreach my $i (@db){ > if($i->[0] >= $dates[0] && $i->[0] <= $dates[1]){ > print "Found: ",join(' ',@{$i}),"\n"; > } > } > } > > __END__ > > try it and see what happen. i am sure you can make it better. > > david > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > This e-mail is intended only for the named addressee(s) and may contain confidential and/or privileged information. If you are not the named addressee (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. The unauthorised use, disclosure, distribution or copying of the contents in this e-mail is strictly prohibited." This e-mail is intended only for the named addressee(s) and may contain confidential and/or privileged information. If you are not the named addressee (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. The unauthorised use, disclosure, distribution or copying of the contents in this e-mail is strictly prohibited." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]