in reply to Re: Opening Multiple FileHandles w/ Simpler Code
in thread Opening Multiple FileHandles w/ Simpler Code

Absolutely Brilliant! Perfection! Thanks!
  • Comment on Re^2: Opening Multiple FileHandles w/ Simpler Code

Replies are listed 'Best First'.
Re^3: Opening Multiple FileHandles w/ Simpler Code
by tlm (Prior) on Aug 10, 2005 at 01:50 UTC

    Just keep in mind that certain constructs, such as < > do not accept lexical handles unless they are in "simple" variables. E.g.

    while ( <$handles[ 3 ]> ) { # do something with last line read }
    won't work. You need to do something like this:
    while ( defined( my $line = $handles[ 3 ]->getline ) ) { # do something with $line }
    or
    frobnicate( $handles[ 3 ]->getline ) until $handles[ 3 ]->eof;
    or, if you really prefer to avoid invoking methods on then handle, the you can do this
    my $tmp = $handles[ 3 ]; while ( <$tmp> ) { # go crazy }

    the lowliest monk