Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^5: greater efficiency required (ls, glob, or readdir?)

by ikegami (Pope)
on Aug 27, 2008 at 19:34 UTC ( #707274=note: print w/replies, xml ) Need Help??


in reply to Re^4: greater efficiency required (ls, glob, or readdir?)
in thread greater efficiency required (ls, glob, or readdir?)

Do you deem "Died at x.pl line y." acceptable for something that could be an I/O or spawning error? (It doesn't if it is and which it is).

Replies are listed 'Best First'.
Re^6: greater efficiency required (ls, glob, or readdir?)
by kyle (Abbot) on Aug 27, 2008 at 19:38 UTC

    In this case, cat outputs its own error with what would be $!.

    cat: file-that-does-not-exist: No such file or directory

    It might be cleaner to "exit 1 if $?" rather than die to avoid the useless "Died" message (but then you don't get the line number).

    Update: Hmmm, when I hit 'reply', the node I replied to said only, Do you deem "Died at x.pl line y." acceptable?

Re^6: greater efficiency required (ls, glob, or readdir?)
by JavaFan (Canon) on Aug 27, 2008 at 19:40 UTC
    Oh, if you don't like the died message, replace it with
    exit 1 if $?;
    A few character strokes more, but still a very short line.

    And no, the program won't be silent. "cat" is perfectly able to tell the user why it can't read the file.

      True, I overlooked cat's error message. It'll still be silent for spawning errors, although those will be far less common.
        I'm not sure what you mean by "spawning errors", but if 'cat' happens to be chasing mice outside my $PATH, Perl will tell me:
        $ PATH=/tmp /usr/bin/perl -wE '$_ = `cat /etc/motd`' Can't exec "cat": No such file or directory at -e line 1.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://707274]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2020-11-28 10:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?