Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #248682

Re: grep: show matching line from pattern file

From Will Mengarini <seldon@eskimo.com>
Newsgroups linux.debian.user
Subject Re: grep: show matching line from pattern file
Date 2022-06-03 00:30 +0200
Message-ID <Eu1ui-2806-1@gated-at.bofh.it> (permalink)
References <EsaLo-XqP-13@gated-at.bofh.it> <EsaV4-XJm-7@gated-at.bofh.it> <Esc0N-YkA-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Greg Wooledge <greg@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.

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$
--------------------------------

-- 
                 Will Mengarini  <seldon@eskimo.com>
                perl -le"print unpack '%C*',MENGARINI"

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

grep: show matching line from pattern file Jim Popovitch <jim@k4vqc.com> - 2022-05-28 22:00 +0200
  Re: grep: show matching line from pattern file The Wanderer <wanderer@fastmail.fm> - 2022-05-28 22:10 +0200
    Re: grep: show matching line from pattern file Greg Wooledge <greg@wooledge.org> - 2022-05-28 23:20 +0200
      Re: grep: show matching line from pattern file The Wanderer <wanderer@fastmail.fm> - 2022-05-28 23:30 +0200
      Re: grep: show matching line from pattern file Jim Popovitch <jim@k4vqc.com> - 2022-05-29 19:50 +0200
      Re: grep: show matching line from pattern file Will Mengarini <seldon@eskimo.com> - 2022-06-03 00:30 +0200
        Re: grep: show matching line from pattern file David Christensen <dpchrist@holgerdanske.com> - 2022-06-03 01:00 +0200
          Re: grep: show matching line from pattern file Will Mengarini <seldon@eskimo.com> - 2022-06-03 02:20 +0200
  Re: grep: show matching line from pattern file Jörg-Volker Peetz <jvpeetz@web.de> - 2022-05-29 15:10 +0200
    Re: grep: show matching line from pattern file David Wright <deblis@lionunicorn.co.uk> - 2022-05-29 15:50 +0200
      Re: grep: show matching line from pattern file duh <fill_in_the_blanks@email.com> - 2022-06-02 21:20 +0200
        Re: grep: show matching line from pattern file Greg Wooledge <greg@wooledge.org> - 2022-06-02 21:20 +0200
          Re: grep: show matching line from pattern file Richard Hector <richard@walnut.gen.nz> - 2022-06-04 05:00 +0200

csiph-web