http://www.perlmonks.org?node_id=1153477


in reply to Re^2: perl not going to error path
in thread perl not going to error path

"Now when i pass a non numeric offset, i get an error that says argument non numeric but i dont get the die error message"

That's because seek is effectively calling die() before you get a chance to. It's saying "pass in an integer or I'll proceed no further. This is an error, and I'm killing all processes".

It's hard to get seek to fail when your argument is an integer, because (at least on Unix), it allows you to seek past the end of the file.

This sounds like an XY Problem. Why don't you tell us what it is you're trying to do? seek() as you've noticed, handles its own errors.

UPDATE:

"now when i pass a non numeric offset, the script dies and throws the die error message and the exit value is non zero. this is what i want but i don't understand why i need the quotes."

Well, you didn't include the error message from $!, but I'll bet it's something along these lines: "Bad file descriptor...". You've hit your die, but it's because quoted "$fh" is no longer a valid file handle anymore. It's pretty much saying that it can't open the file.

Again, tell us what you're really trying to do in the bigger picture.