paragkalra has asked for the wisdom of the Perl Monks concerning the following question:

I have written a Perl script which prints lot of things and output results on the command prompt i.e STDOUT

How can I modify it to print the output messages both to STDOUT and a Log file.

Do I need to install some specific Perl module.

  • Comment on Redirecting the output to STDOUT & a LOG file

Replies are listed 'Best First'.
Re: Redirecting the output to STDOUT & a LOG file
by Corion (Patriarch) on Mar 16, 2009 at 10:02 UTC

    This is a FAQ. See perlfaq5 about "How do I print to more than one file at once?", or type perldoc -q more than one file at your command prompt.

Re: Redirecting the output to STDOUT & a LOG file
by Bloodnok (Vicar) on Mar 16, 2009 at 10:19 UTC
    What Corion didn't tell you directly is the answer to your 2nd question which is ... no, you don't need to install any specific perl module - just refer to the docs to which he directed you.

    IMO, a significant clue lies in the provenance of this language (some might call it a way of life) - being the humble *NIX script ... & the means of re-direction therein.

    A user level that continues to overstate my experience :-))