Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Automatic trace statements in program

by orbital (Scribe)
on Mar 20, 2001 at 23:40 UTC ( #65785=note: print w/replies, xml ) Need Help??


in reply to Automatic trace statements in program

If all your trying to do is write to a specific log file, operations that the program preformed try this:

open(LOG,">>logfile.log") || die "can't open file: $!\n" select LOG; print "$time batch job completed normally\n"; close(LOG) || die "LOG didn't close: $!\n";

A few things to note:

the >> in open refer to opening the file for append, if you want to destroy the file during each execution use a single >

select followed by a FILEHANDLE sets all commands that normally directed towards STDIN (print, printf write etc..) to point towards the specified FILEHANDLE.

One other note it is important to error check opening and closing of files, if the file didn't close properly you would want to know before your HD filled up.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://65785]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2023-09-26 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?