in reply to Re: Perl output on console as well as on text file
in thread Perl output on console as well as on text file

I don't have only single print statment. i have big perl script in which i am using so many perl commands as well as no. of print statements. i want whole output to be printed on console as well as on text file.also i don't want to install any other module fom CPAN. is still any way to get out of this problm

  • Comment on Re^2: Perl output on console as well as on text file

Replies are listed 'Best First'.
Re^3: Perl output on console as well as on text file
by Anonymous Monk on Jan 05, 2015 at 11:34 UTC

    I don't have only single print statment. i have big perl script in which i am using so many perl commands as well as no. of print statements. i want whole output to be printed on console as well as on text file.also i don't want to install any other module fom CPAN. is still any way to get out of this problm

    Its called a subroutine, instead of

    print $fh $str; ... print $fh $str; ... print $fh $str;
    you write
    DoublePrint( $fh, $fh2, $str ); ... DoublePrint( $fh, $fh2, $str ); ... DoublePrint( $fh, $fh2, $str );
    where DoublePrint prints to STDOUT and something else