I would create two print statements. One goes to STDOUT and the other one goes into a global array. My logfile will be created from the global array. So I plan to create this logfile in case my script crashes/dies.
Are you printing the same thing to both STDOUT and the global array "log file", or does the log file get different information than STDOUT?
The normal unix way of doing things is to print output data to STDOUT (e.g. stuff that might be used by a downstream process in a pipeline) and to print log and/or error messages to STDERR, which is typically unbuffered by default.
If the idea is to handle a crash/die situation by making sure that all of stdout gets saved to a "log" file, unix users would just put a "tee [-a] log.file" command in the pipeline right after the perl script.
If the log data is different from stdout data, and the idea is to handle a crash/die by saving a trace of how far you got, just print log data to STDERR, and redirect stderr to a file on the command line, or open STDERR to a named file within your script.
But maybe I'm missing your point, because it wasn't clear from the OP what you're hoping to accomplish.
In reply to Re: creating log file question
by graff
in thread creating log file question
by EchoAngel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |