use IO::Scalar; my $fh = IO::Scalar->new; print $fh "foo\n"; # Rather than $fh->print ... # or, if you prefer select $fh; print "bar\n";