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:
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.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" };
In addition, system handles all the cleanup from failed commands. If you want to test $@, try
Try them both - they exhibit different behaviors of eval and die.eval { die "Hello!\n" }; print "Reason: $@\n"; eval { die "Hello!" }; print "Reason: $@\n";
------
We are the carpenters and bricklayers of the Information Age.
Vote paco for President!
In Section
Seekers of Perl Wisdom