in reply to Question about eval

At what point of processing the script does an eval function get parsed ? Is it not compile time ? Or is it run time ?
There are two types of eval which behave quite differently:  eval STRING and eval BLOCK. If eval is passed a string parameter, it is parsed and compiled at runtime; if it is passed an unquoted block of code, it is parsed and compiled at compile-time.
Also, why does
if(require "module/that/does/not/exist") { print "loaded module ok\n"; }else{ print "could not load module $@\n"; }
not work ?
require dies if it can't find the file it's looking for, rather than simply returning an error. require is a sort of assertion, and if it fails it's considered too severe to keep on running.
if I do
eval { require "module/that/does/not/exist"; }
nothing happens ? Do I have to check $@ after eval ? Do i have to check if $@ is defined after every eval call ?
Yes, you have to check $@ after every eval to see if anything in the eval failed.
Also, why does this small print statement not generate error ?
print petrol "hello there !";
If you run perl without warnings and strict, undeclared variables simply spring into existence. In this case, petrol is created the first time you use it. It doesn't go anywhere, so output to it is simply discarded. If you add:
use warnings; use strict;
to the top of your Perl code, you'll get an error if you try to do this. I recommend starting off all of your scripts that way.