Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: select and IO::Handle

by danger (Priest)
on Aug 04, 2001 at 01:21 UTC ( #102168=note: print w/ replies, xml ) Need Help??

in reply to select and IO::Handle

I found that using either of the tied interfaces worked as you expect (both documented in the POD's for Perl-5.004 or later):

#!/usr/bin/perl -w use strict; use IO::Scalar; my $string; tie *OUT, 'IO::Scalar', \$string; select OUT; print "line 1\nline 2\n", "line 3\n"; select STDOUT; print "The string contains:\n$string\n"; ### OR this way: $string = ''; my $SH = IO::Scalar->new_tie(\$string); $SH->print("line 1\n"); # use the OO method print $SH "line 2\n"; # use it like a filehandle select $SH; # select it as default output handle print "line 3\n"; select STDOUT; print "The string contains:\n$string" __END__

Comment on Re: select and IO::Handle
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://102168]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2015-10-04 12:20 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (102 votes), past polls