Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^5: Why am I getting "premature end of script header"?

by imp (Priest)
on Nov 27, 2006 at 22:54 UTC ( #586353=note: print w/ replies, xml ) Need Help??


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; } }


Comment on Re^5: Why am I getting "premature end of script header"?
Download Code
Re^6: Why am I getting "premature end of script header"?
by lokiloki (Beadle) on Nov 27, 2006 at 23:16 UTC
    well, I have a package that has a few separate programs, and I want the variables to be shared by all of them. I use my for local variables, but the variables that i want shared i just dont declare... i tried to use our on them, but it had unintended consequences that I couldn't figure out...
      I also tried to use use vars qw($name) but that didnt work either...
        We could help you identify the source of those problems, but only if you provide enough information. Saying unintended consequences and didnt work either doesn't give us anything to work with.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://586353]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2014-07-30 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls