in reply to execution log

I'm making assumptions but I guess you mean that errors and warnings generated by warn or die go to STDERR whereas normal messages generated by a plain print without a filehandle go to STDOUT. On a *nix system you can run a script from the shell (Bourne, Korn, Bash) like this

script_name > output_file 2>&1

which directs STDOUT of the script into the "output_file" and also directs STDERR (file descriptor 2) into STDOUT (file descriptor 1). That way, you can get both STDOUT and STDERR into one file. I'm not sure what you would do in a MS Windows environment, perhaps other Monks can tell you (and me) what to do there.

I hope this is of use.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: execution log
by ikegami (Patriarch) on May 04, 2006 at 20:59 UTC
    That also works in Windows (except 95/98/ME, I think)
Re^2: execution log
by yburge (Acolyte) on May 04, 2006 at 23:34 UTC
    Please excuse my ignorance (I'm just getting started with Perl, and I haven't done any programming since I was in school 25 years ago), but do I place that statement in my script? UPDATE: BTW, I'm working in Windows 2000, if that makes a difference.
      Not in the script, no. You use that syntax from the command-line to invoke the script, either in a *nix shell or from a DOS prompt, except under DOS you invoke Perl and give it your script name as the first argument. I normally use Solaris but I managed to turf the kids off the PC to try out what happens under Windows XP. I put this little script together; I called it fred

      use strict; use warnings; print "The beginning\n"; my $flag = 1; warn "Flag set\n" if $flag; die "Farewell, cruel world\n";

      and ran it firstly without any redirection of STDOUT or STDERR like this

      C:> perl fred The beginning Flag set Farewell, cruel world C:>

      I then tried redirecting STDOUT to a file

      C:> perl fred > fred.out Flag set Farewell, cruel world C:> type fred.out The beginning C:>

      Finally, I tried redirecting STDERR as well

      C:> perl fred > fred.out 2>&1 C:> type fred.out The beginning Flag set Farewell, cruel world C:>

      Astonishingly, it seems to work just like Solaris. All they need to do now is get their slashes the right way round and we'll be laughing.

      Cheers,

      JohnGG