-p, open errors and exit status

A

Andre Majorel

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).
 
B

Ben Morrow

Andre Majorel said:
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
 
R

Richard Gration

"Ben Morrow" said:
--
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] *
(e-mail address removed)

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!
 
C

Chris Mattern

Richard said:
--
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] *
(e-mail address removed)


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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top