Hi, 

Tielman Koekemoer (TNE) <[EMAIL PROTECTED]> asked:
> Thanks for the help. So I cannot use an array or hash in 
> angle brackets as file handle. I have a variable amount of 
> files which I'd like opened and the contents shuffled. What 
> would be the best way to do this as my next idea also did not work? 

You'll have to use the OO interface to the I/O stuff.
Here's a small example:

#!/usr/bin/perl -w

use strict;
use IO::File;

my @infh;

foreach my $file ( @ARGV ){
  if( my $fh = new IO::File $file ){
     push @infh, $fh;
  } else {
    die "Failed to open input file '$file': $!";
  }
}

while( @infh ){
  foreach my $fh (@infh){
    print $fh->getline();
    if( $fh->eof() ){
      $fh->close();
      $fh = undef;
    }
  }
  @infh = grep { defined $_ } @infh;
}

__END__

HTH,
Thomas

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to