-p, open errors and exit status

Discussion in 'Perl Misc' started by Andre Majorel, Jan 20, 2004.

  1. Could you suggest a succint way to make perl exit with a non
    zero-status when the file on the command line can't be opened ?

    perl -i -pe 's/foo/bar/' /some/file || echo "it failed"

    Ugly is okay as long as it's succint (it's in a makefile and
    it's best to keep it concise).

    --
    André Majorel <URL:http://www.teaser.fr/~amajorel/>
    Agree with them now, it will save so much time.
     
    Andre Majorel, Jan 20, 2004
    #1
    1. Advertising

  2. Andre Majorel

    Ben Morrow Guest

    Andre Majorel <> wrote:
    > Could you suggest a succint way to make perl exit with a non
    > zero-status when the file on the command line can't be opened ?
    >
    > perl -i -pe 's/foo/bar/' /some/file || echo "it failed"
    >
    > Ugly is okay as long as it's succint (it's in a makefile and
    > it's best to keep it concise).


    The only way I can find is:

    perl -i -pe'BEGIN{$SIG{__WARN__}=sub{die shift}}' -e's/foo/bar/'

    .. I would have expected -MFatal=open to work, but it seems not to...

    Ben

    --
    For the last month, a large number of PSNs in the Arpa[Inter-]net have been
    reporting symptoms of congestion ... These reports have been accompanied by an
    increasing number of user complaints ... As of June,... the Arpanet contained
    47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] *
     
    Ben Morrow, Jan 20, 2004
    #2
    1. Advertising

  3. OT: Far OUT! (was Re: -p, open errors and exit status)

    In article <bujl0o$5it$>, "Ben Morrow"
    <> wrote:

    > --
    > For the last month, a large number of PSNs in the Arpa[Inter-]net have been
    > reporting symptoms of congestion ... These reports have been accompanied by an
    > increasing number of user complaints ... As of June,... the Arpanet contained
    > 47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] *
    >


    I just read / skimmed this page. It made my spine tingle. Was that really
    the *whole* internet?! Total Perspective Vortex or what :) Made me think
    of the story of the fledgling internet becoming unusable due to DNS
    traffic alone!
     
    Richard Gration, Jan 20, 2004
    #3
  4. Re: OT: Far OUT! (was Re: -p, open errors and exit status)

    Richard Gration wrote:
    > In article <bujl0o$5it$>, "Ben Morrow"
    > <> wrote:
    >
    >
    >>--
    >>For the last month, a large number of PSNs in the Arpa[Inter-]net have been
    >>reporting symptoms of congestion ... These reports have been accompanied by an
    >>increasing number of user complaints ... As of June,... the Arpanet contained
    >>47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] *
    >>

    >
    >
    > I just read / skimmed this page. It made my spine tingle. Was that really
    > the *whole* internet?! Total Perspective Vortex or what :) Made me think
    > of the story of the fledgling internet becoming unusable due to DNS
    > traffic alone!


    DNS? Who dat? Back then, you just kept hostnames for the entire Arpanet
    in your /etc/hosts.

    Chris Mattern
     
    Chris Mattern, Jan 20, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FuZHk=?=

    Code to Exit Web App and Exit Internet Explorer

    =?Utf-8?B?U2FuZHk=?=, Aug 3, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    7,962
    =?Utf-8?B?U2FuZHk=?=
    Aug 5, 2005
  2. jacob navia
    Replies:
    3
    Views:
    575
    Nick Keighley
    Feb 24, 2010
  3. Keith Thompson
    Replies:
    10
    Views:
    711
    Tim Rentsch
    Mar 3, 2010
  4. kaleem
    Replies:
    8
    Views:
    862
    Tad McClellan
    Dec 14, 2006
  5. Ronen Yacov
    Replies:
    1
    Views:
    243
    David Dorward
    Nov 5, 2007
Loading...

Share This Page