http://qs321.pair.com?node_id=110284


in reply to Eval and system()

It's not being caught in the compile phase. The program compiles just fine.

You are working just fine with eval ... it's system (specifically on Unix) that's tripping you up. Try doing:

eval { system "fake command" && print "Blah1\n" }; eval { system "fake command" || print "Blah2\n" }; eval { system "ls" && print "Blah3\n" }; eval { system "ls" || print "Blah4\n" };
Unix commands are built off of the C libraries (for the most part). The standard C libraries, for reasons which will be left to your imagination, use '0' to indicate success and non-zero to indicate failure. Thus, the Unix commands tend to follow this (rather stupid) paradigm.

In addition, system handles all the cleanup from failed commands. If you want to test $@, try

eval { die "Hello!\n" }; print "Reason: $@\n"; eval { die "Hello!" }; print "Reason: $@\n";
Try them both - they exhibit different behaviors of eval and die.

------
We are the carpenters and bricklayers of the Information Age.

Vote paco for President!