[Bioperl-l] What happens to STDOUT?

Marc Logghe MarcL at DEVGEN.com
Fri Mar 31 07:59:20 UTC 2006


> You can redirect to STDOUT by a glob (setting the filehandle 
> to *\STDOUT).
> Note that this doesn't use '-file', but '-fh.'   It's in the 
> SeqIO HOWTO:
> 
> # create one SeqIO object to read in, and another to write out
> my $seqin = Bio::SeqIO->new(-fh     => \*STDIN,
>                             -format => $informat);

A little off topic, but might be usefull as well.
Sometimes you don't know whether the input sequences will come from
stdin or from a file. Therefor, I ofen found myself writing things like:
my $seqin = Bio::SeqIO->new(-format => $informat, $file ? (-file =>
$file) : (-fh => \*STDIN));
This can be replaced by:
my $seqin = Bio::SeqIO->new(-format => $informat, $file ? -fh =>
\*ARGV);
In that way, you have the same magic as the diamond/pulp fiction
operator <>

Cheers,
Marc




More information about the Bioperl-l mailing list