in reply to Re: Re: Re: Re: Re: Re: Dumping data
in thread Dumping data

I fail to see how to print to both the file and STDOUT with a single print, given that I only want to run the script once.

# method 1 select RESULT; print "something\n"; select STDOUT; print "something\n"; # method 2 select RESULT; do_test(); select STDOUT; do_test(); sub do_test { print "something\n"; }
I am a lazy programmer, I would prefer to simply cut and paste the stub to the start of the code, instead of trying to work out where to insert select. I know IO::Capture has limitations, but I like a solution that will leave the original code untouched as much as possible.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Re: Re: Dumping data
by Anonymous Monk on Jan 01, 2004 at 11:14 UTC
    *sigh*
    BEGIN { use IO::Tee; $ol = select IO::Tee->new( STDOUT, STDERR, IO::File->new...); }
    I wouldn't encourage things like IO::Capture
      OK, I get your point. That's a good solution. :-)

      I never thought about using IO::Tee. I have learnt something new today. Thanks.