On May 25, 2005, at 10:32, Tielman Koekemoer ((TNE)) wrote:


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?

_BEGIN_

@files=`ls /app2/koekemtn/scripts/dbstats/test`;
$num =1;

foreach $line ( @files ) {

    chomp $line;
    open ( $line , "$line") || die "Cannot open $files[0]\n";
    $file$num = $line;   # Problem assignment!
}


If you need the filehandles in an array, then use an array and read from them using readline(), which accepts any expression:

    while (my $line = readline $files[$n]) {
       // ...
    }

See perldoc -f readline for details.

-- fxn




--
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