in reply to Re: Bulk Reading and Writing of Large Text Files
in thread Bulk Reading and Writing of Large Text Files

Thank you for your response. I have been trying both options. Using your advice my script now reads:
#!/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);
It has worked just yet and I get the following errors:
[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.
I have tried tweaking it a bit but I haven't really got anywhere.

Replies are listed 'Best First'.
Re^3: Bulk Reading and Writing of Large Text Files
by BrowserUk (Patriarch) on May 21, 2013 at 12:29 UTC

    I changed your declaration line

    from:

    my ($record, $date, $outfile, $station, $sstation, $linecnt, $pcntg, @ +values); #.............................^^^^^^^^

    to

    my ($record, $date, $outfile, %stations, $sstation, $linecnt, $pcntg, +@values); #.............................^^^^^^^^^

    You didn't!


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      I was hoping to not have to ask anything again but I am stumped with this one!

      [s1269452@burn MIDAS_DATA]$ perl bulk_reorder_2105.txt midas_wxhrly_19 +9901-199912.txt "1999-12-15 11:00" 19260 19261 19262 [...] exists argument is not a HASH or ARRAY element or a subroutine at bulk +_reorder_2105.txt line 27.
      Thank you

        What does line 27 look like?


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.