heusserm (email not shown publicly)
http://www.xndev.com/AOL IM: MatthewHeusser (
Add Buddy, Send Message)
Matt Heusser is JAPH and an
XP-Er [xprogramming.com]. (The Methodology, not the Operating System.) Right now, he's doing a lot of Test Driven Development in Perl.
Needs local() (Score:2)
Hmmm, I'm not sure that does exactly the same thing, but it might be worth a try...
-Dom
there's also SelectSaver :) (Score:1)
Not sure if you can use IO::String->new() in there, but it could be worth looking at
Too simplistic. (Score:2)
print "foo";
but not for this:
print STDOUT "foo";
nor for anything but the currently selected filehandle.
A more general solution is in TieOut.pm of which copies are scattered around in t/lib directories of various modules, a little invention of chromatic's. Here's one. http://search.cpan.org/src/MSCHWERN/ExtUtils-MakeMaker-6.16/t/lib/. Here's an example of its use. http://search.cpan.org/
Your generalized solution is Too simplistic. (Score:1)
For example:
$r = *STDOUT;
print $r "foo\n";
or
print stdout "foo\n";
(Tying STDOUT won't tie stdout)
Of course, that's fixed in 5.8, but we're not using 5.8.
sigh.
(Most of this from Jeff Klein, who has hubris, but is too lazy to get his own account on use.perl.org
Fork (Score:2)
As an alternative approach, how about forking and piping to yourself?
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers