in reply to printing to STDOUT and a Logfile

If you're on a Unix-like system, you can check out the 'tee' command:


$ man tee

NAME
       tee  - read from standard input and write to standard out-
       put and files

Another option, which I have never used, is Tie::FileHandle::MultiPlex.

Update: One way that I have used 'tee' in the past.

use constant TEE => '| tee '; use constant TO_PRINTER => "| lp -d lex_text"; my $file = REPORT_DIR . "cc_auth_$DATETIME"; open CCAUTH_REPORT, TEE . $file . TO_PRINTER or die $!;

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re: Re: printing to STDOUT and a Logfile
by Kanji (Parson) on Oct 29, 2002 at 01:21 UTC
    Another option, which I have never used, is Tie::FileHandle::MultiPlex.

    ... and if you hunt around CPAN, you'll also find Filter::tee and IO::Tee, which look to be of a similar vein.

    Update: D'oh... shoulda tested the code in the <readmore> before posting. Although it prolly still could be made to work, ybiC's code is simpler.

        --k.