Ruby's File.open throws an exception which the default runtime behavior handles pretty well on its own (not to mention the error message includes the filename which yours doesn't), so yes.
$ ruby -e 'File.open( ARGV.shift, "r" ) { |f| puts f.readlines }' nott +here -e:1:in `initialize': No such file or directory - notthere (Errno::ENO +ENT) from -e:1:in `open' from -e:1
And if you're going to be that pedantic you might want to check for the error from print when you try and print to a filehandle you've opened for reading . . .
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re^3: Search for a string in a file
by Fletch
in thread Search for a string in a file
by Millan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |