in reply to Re^2: String Buffer
in thread String Buffer
In fact, that uses a perlio layer silently.
I've been wishing a perlio layer that allows you to simply open a stream that behaives like any tied handle eg.
use StringBuffer; use PerlIO::Tied; # Note: never close one of the three standard handles. It's almost alw +ays a bad idea. open OLDSTDOUT, ">&=STDOUT"; open STDOUT, ">:tied(StringBuffer)"; # I presume extra arguments to ti +e get passed as extra argument to open print STDOUT "this magically gets put to \$stdout\n"; open STDOUT, ">&=OLDSTDOUT"; print STDOUT "this gets put to the original standard output again\n";
This gets even more useful if you want to use a tied io handle from the command line eg. perl -MPerlIO::Tied -we 'some code' ':tied(SomeModule, arguments)'.
|
|---|