tune has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks!

I have a task to parse some PHP codes and mine some system-wide constants out and apply it in my Perl code as own constants.
I think it is possible by parsing out the constant name, and value from the PHP file, and then eval a constant declaration.
But the Perl interpreter thinks otherwise:

eval "use constant CONST1=>5" or warn $@; # when I run this I get: +Warning: something's wrong at ./consteval.pl line 3.

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".