Perl code to extract data from the range of date

Hi All,

I'm still a newbie in perl programming. I have a data below say in test.tmp

The output in test.tmp will be the same data as above sample in test.tmp . So after i get all the 4th column data within the range of month and year i need, then i will use the foreach () code to execute another command to get the job done :smiley:

Thanks in advance for your help :slight_smile:

#build a month hash
my %month_hash = ( 'jan' => 1, 'feb' => 2, 'mar' => 3, ... ,'dec' => 12);

while (my $line = <FH>){
chomp $line;
my @cols = split (' ',$line);
#mon date year id
if ($cols[2] >= $from_year && $cols[2] <= $to_year && $month_hash{lc($cols[0])} >= $month_hash{lc($from_month)} && $month_hash{lc($cols[0])} <= $month_hash{lc($to_month)} ) {
print "$cols[3]\n";
}
}

Note: There are many scripting lang which produces the desired result . the key is what you want to use and the ability to try and use it. if you give up you will end up being a newbie.

Cheers,
fellow newbie