On 6/2/22 15:13, Will Mengarini wrote:
* Greg Wooledge <g...@wooledge.org> [22-05/28=Sa 17:11 -0400]:
[...]
#!/usr/bin/perl
use strict; use warnings;
[...]
open PATS, "<patterns.txt" || die "can't open patterns.txt";
[...]

You need "or die", not "|| die", because of precedence: what you coded
checks whether "<patterns.txt" is logically true (it is), whereas you
wanted to check whether the result of open() is logically true.


+1  That is a good explanation of a Perl fine point/ gotcha.


In this transcript, the number before the prompt-ending '$' is $?:
--------------------------------
debian/pts/4 bash3 ~ 14:56 0$perl -e 'open "gweeblefleep" || die'
debian/pts/4 bash3 ~ 14:57 0$perl -e 'open "gweeblefleep" or die'
Died at -e line 1.
debian/pts/4 bash3 ~ 14:57 2$
--------------------------------


What is your shell?  PS1?


David

Reply via email to