#!/usr/bin/perl use strict; use warnings; my ($record, $date, $outfile, $station, $sstation, $linecnt, $pcntg, @values); print "Processing \"$ARGV[0]\"...\n"; $date = $ARGV[1]; %stations = map{ $_ => 1 } @ARGV[ 2 .. $#ARGV]; $outfile = $date.".txt"; $outfile =~ s/ /-/; print "For Date: $date and Station: $station\n\n"; $linecnt = `wc -l < $ARGV[0]`; open (INFILE, $ARGV[0]); open (OUTFILE, ">>", $outfile); while () { $pcntg = int (($. / $linecnt ) * 100) ; print "$pcntg %\r"; chomp(); $record = $_; @values = split (',',$record); $sstation = $values[5]; $sstation =~ s/ //g; if( $values[0] eq $date && exists $stations{ $sstation } ) { print OUTFILE $record."\n"; # print "xx".$values[5]."xx\n"; print "Record written to $outfile...\n"; last; } } print "\nFinished\n"; close (INFILE); close (OUTFILE);