rah has asked for the wisdom of the Perl Monks concerning the following question:
I've come across a strange phenomenon I'm hoping someone can shed some light on. It appears that some logical "or"s in my code behave differently if run from the command line, than if called from the scheduler or from a scheduler service I built.
The code works fine when run on the command line (this is 5.6.1 on Win2K). I've seen it in a couple of different places. The problem statements are part of a script I inherited which parses output from some fax software, reformats it then dumps out a text file. I've also seen it in another simpler script. A snippet should serve to illusatrate. Based on the varying circumstances in which I've observed this, the rest of the code is irrelevant. Anyway here goes:
When executed on the command line, it opens the logfile and continues to execute. When called via "at" or the simple scheduler I wrote, it opens the logfile AND dies. Similarly:$logfile = "C:\\somepath\\somefile"; open (LOGFILE, "$logfile) || die "Can't open $logfile: $!"; do something with the file close (LOGFILE);
alternate form fails as well:$cmd = "G:\\somepath\\bin\\vfxolog -U vsifax"; $return = `$cmd` or die "Can't execute $cmd: $!";
Same behavior as the filehandle operation above. From the command line this dumps the Vsi-Fax log file as directed, and continues processing. But, from "at" or my scheduler, it executes the command AND dies.$cmd = "G:\\somepath\\bin\\vfxolog -U vsifax"; system ( $cmd ) || die "Can't execute $cmd: $!";
I could sort of understand how precedence might change based on context, but I can't figure out how an "or" becomes an "and". What am I missing?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: When is a logical or not logical
by BrowserUk (Patriarch) on May 10, 2003 at 03:27 UTC | |
by rah (Monk) on May 10, 2003 at 03:41 UTC | |
by NetWallah (Canon) on May 10, 2003 at 05:17 UTC | |
|
Re: When is a logical or not logical
by eduardo (Curate) on May 10, 2003 at 02:53 UTC | |
|
Re: When is a logical or not logical
by dws (Chancellor) on May 10, 2003 at 06:29 UTC | |
|
Re: When is a logical or not logical
by bobn (Chaplain) on May 10, 2003 at 03:09 UTC |