Tim Johnson wrote:
One solution would be to use a custom subroutine instead of print()ing
directly.  If you need something more robust, there are modules out
there that can do the heavy lifting for you.


#####################

use strict;
use warnings;
open(OUTFILE,">script.log") || die "Couldn't write to script.log!\n";

- or die is better than || die
- why go to all the trouble of giving an error if you don't use the error? (IE $!) :)


PrintOut("This goes to a file as well as the screen.\n");

Why use a subroutine just to print to a filehandle?

Also you didn't ever close it which could be bad :)

use strict;
use warning;
open FH, '>./script.log' or die "Open script.log for writing failed: $!";
print LOG "print to LOG like whenever you want to add something to it\n";
close FH;

You may also want to consider locking it either with flock if your system supports it or creating/deleting/checking for a lock file.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to