[boulder.pm] hash for multiple filehandles?

Robert L. Harris Robert.L.Harris at rnd-consulting.com
Thu Jun 29 12:54:06 CDT 2000



Ok,
  I have a very large file.  it has about 30 record types.  We currently 
use about 15 of those.  Right now, I open 15 filehandles, manucally, 
have 15 print statements, and 15 closes.  There has got to be a
better way.

    open(OUT01, ">$Out.01") || die "Can't open Outputfile $Out.01 :$!:\n";
    open(OUT26, ">$Out.26") || die "Can't open Outputfile $Out.26 :$!:\n";
    open(OUT36, ">$Out.36") || die "Can't open Outputfile $Out.36 :$!:\n";
    open(OUT37, ">$Out.37") || die "Can't open Outputfile $Out.37 :$!:\n";
    while(<INFILE>) {
      # do some processing
      .
      .
      .

      print OUT01 "$Line\n" if ($RecNum eq "01");
      print OUT26 "$Line\n" if ($RecNum eq "26");
      print OUT36 "$Line\n" if ($RecNum eq "36");
      print OUT37 "$Line\n" if ($RecNum eq "37");
    }
    close(OUT01);
    close(OUT26);
    close(OUT36);
    close(OUT37);



:wq!
---------------------------------------------------------------------------
Robert L. Harris                |  Micros~1 :  
Senior System Engineer          |    For when quality, reliability 
  at RnD Consulting             |      and security just aren't
                                \_       that important!
DISCLAIMER:
      These are MY OPINIONS ALONE.  I speak for no-one else.
FYI:
 perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'




More information about the Boulder-pm mailing list