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


in reply to Re^4: Why am I getting "premature end of script header"?
in thread Why am I getting "premature end of script header"?

BEGIN doesn't need to be at the beginning of the script, but it will make it easier for you to to follow the execution if it is.

If you want to keep a variable to track whether the module is loaded you should use our, as you should always use strict (and warnings).

use strict; use warnings; our $lwpavailable = 0; BEGIN { eval (" use LWP::UserAgent; use HTTP::Request::Common; "); if ($@) { $lwpavailable = 0; } else { $lwpavailable = 1; } }