Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by JavaFan (Canon)
on Aug 27, 2008 at 19:40 UTC ( #707277=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^7: greater efficiency required (ls, glob, or readdir?)
by ikegami (Pope) on Aug 27, 2008 at 21:01 UTC
    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.

        Remember, the file name is a variable in this discussion, so you're method of calling cat is unacceptable. First fix the major bug that your script treats file names as shell commands, then you'll notice it's silent.

        Update: eh? It's suppose to be. Since when does open output error messages on its own!

        $ PATH=/tmp /usr/bin/perl -we 'open my $fh, "-|", "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://707277]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2021-01-18 07:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?