in reply to Parsing Text from Object Header that prints to STDOUT

Does it explicitly print to STDOUT, or just to the currently selected handle?

If the latter, and you have v5.8.x you could do something like (untested)

my $buf; open( my $fh, '>', \$buf ) or die "Write to buffer failed\n"; my $hold = select( $fh ); my $aln2 = $factory->align($seq_array_ref); select $hold; # find desired line in $buf my ($score) = $buf =~ /SCORE (\d+)/;

the lowliest monk

Replies are listed 'Best First'.
Re^2: Parsing Text from Object Header that prints to STDOUT
by monkfan (Curate) on Apr 20, 2005 at 17:24 UTC
    It seems that it does *explicitly* print to STDOUT. I tried your snippet under my code plus
    print "SCORE I WANT = $score\n";
    It still print those all output plus: SCORE I WANT = <blank>
    Regards,
    Edward


    PS. How did you change your name? I thought it is never possible ;-)

      I like davidrw's idea, though I have never used it myself. This also works, if you have v5.8.x:

      my ( $aln2, $buf ); { local *STDOUT; open( STDOUT, '>', \$buf ) or die "Write to buffer failed\n"; $aln2 = $factory->align($seq_array_ref); } # find desired line in $buf my ($score) = $buf =~ /SCORE (\d+)/;

      the lowliest monk