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

If you have 100's of print statements in your code, would you rather use a transparent stub or go and modify everyone of your print statements?
Neither. I'd use select.
Please don't make such comment if you don't understand the code.
So you don't see IO::Capture as poorly thought out (it would appear you don't understand it so well)?

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Re: Dumping data
by Roger (Parson) on Jan 01, 2004 at 10:23 UTC
    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.

      *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.