#!/usr/bin/perl use strict; use warnings; my ($record, $date, $outfile, $station, $sstation, $linecnt, $pcntg, @values); # creating variables for user specification of date and station print "Processing \"$ARGV[0]\"...\n"; $date = $ARGV[2]; $station = $ARGV[1]; # create output file named after date being investigated $outfile = $date.".txt"; $outfile =~ s/ /-/; # counting number of lines 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 && $sstation eq $station ) { print OUTFILE $record."\n"; # print "xx".$values[5]."xx\n"; print "Record written to $outfile...\n"; last; } } print "\nFinished\n"; close (INFILE); close (OUTFILE);