in reply to How to write to log files?

package mylog; use strict; use Data::Dumper; open LOGFILE, ">log.txt"; sub log { print LOGFILE, Dumper @_; } sub END { close LOGFILE; } #now in your main proggie &mylog::log("This is a logged message");

There are many better variations, but this is a good first module.

____________________
Jeremy
I didn't believe in evil until I dated it.

Replies are listed 'Best First'.
(RhetTbull) Re: Re: How to write to log files?
by RhetTbull (Curate) on Nov 20, 2001 at 18:46 UTC
    One small error: there shouldn't be a comma after print LOGFILE. The line should read:
    print LOGFILE Dumper @_;