in reply to Re: Problem with GetOptions
in thread Problem with GetOptions
I used the "print join" suggestion to see what was going on and used single quotes in the string to prevent GetOptions splitting the log command.
I then saw that the script was tring to open the log file with ">>$log", which of course failed with a pipe for a log file. I removed the ">>" and it now works as desired.
Is there a foolproof way to only add the ">>" if the log file is a file rather than a pipe?
Is it as simple as checking for the pipe character at the start of the string? Something like:
Thanks,$logfilename = $log; if (substr($log, 0, 1) ne "|") { $logfilename = ">>" . $log; } if (!open STDOUT, $logfilename) { die "Can't write to $logfilename: $! +";}
R.
--
Robin Bowes | http://robinbowes.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Problem with GetOptions
by ysth (Canon) on Dec 23, 2004 at 02:29 UTC | |
by robinbowes (Beadle) on Dec 23, 2004 at 17:10 UTC |