in reply to Perl output on console as well as on text file

This may seem to be obvious trivial, but you could simply wrap all your printing in a function that prints twice, once to SDTOUT and once to a file.
  • Comment on Re: Perl output on console as well as on text file

Replies are listed 'Best First'.
Re^2: Perl output on console as well as on text file
by shyamasoni (Initiate) on Jan 05, 2015 at 10:28 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

      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