Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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__

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2016-09-25 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (474 votes). Check out past polls.