Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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

Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2022-08-08 03:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found