On Wed, Jun 27, 2001 at 04:54:17PM -0700, Paul wrote:
> Another trick -- use FileHandle and put them into an array.
> 
>   my @FILE;
>   for (1..5) {
>      $FILE[$_] = new FileHandle "CHR$_" or die "CHR$_: $!";
>   }
> 
> now you can say:
> 
>     print $FILE[$_] ">$k\t$all_genes{$k}\n";

This doesn't actually work, for obscure reasons having to do with parsing
and such.  It's documented thusly in perldoc -f print:

    Note that if you're storing FILEHANDLES in an array or other
    expression, you will have to use a block returning its value
    instead:

        print { $files[$i] } "stuff\n";
        print { $OK ? STDOUT : STDERR } "stuff\n";

In other words, print can't handle anything other than a simple scalar value
as its filehandle argument, unless you use the above block form.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

Reply via email to