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


in reply to Why am I getting "premature end of script header"?

use is evaluated at compile time, which eval can't catch. There are a few ways around this:
# Option 1 - string eval, test $@ eval "use HTTP::Request::Common"; if ($@) { # Missing } # Option 2 - string eval with return value of 1 if (eval "use HTTP::Request::Common; 1;") { # Loaded, good } else { # Missing } # Option 3 - require and import eval { require HTTP::Request::Common; HTTP::Request::Common->import; }; if ($@) { # Not found }
If I recall correctly option #2 is preferred.