Teamsolco wrote: > > : You should check the return from unlink. > : system() returns true on failure and false on success so using 'or' will > : cause it to die on success and the $! variable will not contain any > : useful information as system() doesn't set $!. The system() entry in > : perlfunc.pod describes this behaviour and the correct way to use > : system(). > : You should check the return from chmod. > > I'm sure I read it somewhere, but I had forgotten about the qwirky > system() return. Based on your recommendation, I have fully rewritten > that (and similar) segment of code to be more sensitive to failure ? (useless $! values will just come with the territory): > > unless ((unlink($path_fifo)) && ((system("mkfifo $path_fifo")) || (chmod(0600, > $path_fifo)))) { > die("Cannot initialize $path_fifo: $!"); > }
You are still not going to get the correct error message from system() as it doesn't set $!. If you use POSIX::mkfifo() this will work correctly. As an aside, I dislike using excess parenthesis (this is not Lisp!) use POSIX 'mkfifo'; die "Cannot initialize $path_fifo: $!" unless unlink $path_fifo and mkfifo $path_fifo and chmod 0600, $path_fifo; > : > our ($hndLOG, $hndFIFO); > : > : Why use 'our' and not 'my'? Why use scalars and not filehandles? > > I'm using 'our' because the objective is to use it globally through the > application's many subs. The compiler forced me to use scalars by > throwing a "Cannot use constants..." type error when attempting to use > the traditional, 'HNDFIFO' and 'HNDLOG' variable names in "our (HNDFIFO, > HNDLOG);" fashion. What I have now is working. Do you have a better > recommendation? Perl's filehandles are "global". Unless you are using packages, filehandles, like directory handles, subroutine names, labels, etc. are globally accessible. our() just lets you create "global" scalars, arrays and hashes when strict is in use and it has the same scoping rules as my(). So, to summarize, "use strict" requires you to declare all scalars, arrays and hashes with my() or our() which both enforce the same block or file scoping rules. Without "use strict" all scalars, arrays and hashes which are not declared with my() or our() are scoped to the current package. All variables that are not scalars, arrays or hashes are package scoped. Since filehandles are neither scalars, arrays or hashes you cannot declare them with my() or our(). If Perl's standard filehandles were working before then you obviously are not using packages so using "global" scalars instead does not really provide any benefits IMHO. :-) > : It is not clear from the snippet you provided what the problem is. > : Sometimes errors are reported for the wrong line number. I know from > : experience that converting Perl4 code to Perl5 can at times be quite > : challenging. It would help a lot to see the original Perl4 code. > > There isn't much left of the original Perl4 code, aside from its legacy > present in the resulting hodge-podge conversion, but thanks. You mean you don't use CVS so you can undo any fatal changes? :-) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>