It has worked just yet and I get the following errors:#!/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 (<INFILE>) { $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);
I have tried tweaking it a bit but I haven't really got anywhere.[s1269452@burn MIDAS_DATA]$ perl bulk_reorder_2105.txt midas_wxhrly_19 +9901-199912.txt "1999-12-15 11:00" 19260 Global symbol "%stations" requires explicit package name at bulk_reord +er_2105.txt line 10. Global symbol "$stations" requires explicit package name at bulk_reord +er_2105.txt line 14. Global symbol "%stations" requires explicit package name at bulk_reord +er_2105.txt line 27. Execution of bulk_reorder_2105.txt aborted due to compilation errors.
In reply to Re^2: Bulk Reading and Writing of Large Text Files
by Sterling_Malory
in thread Bulk Reading and Writing of Large Text Files
by Sterling_Malory
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |