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


in reply to constant and eval (are they enemies?)

eval returns whatever the block of code returns. A block of code returns the return value of the last evaluated statement. use is a compile-time keyword, and at runtime, nothing happens in your evaled code, so it returns undef. Undef is false, so $@ is warned. But because nothing went wrong, $@ is empty, and warn warns "something's wrong".

Fix it like this:

eval "..."; warn $@ if $@;

Or like this (make it return true):

eval "...; 1;" or warn $@;
The first solution is better, imho.

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.