Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Importing variables (not functions) from in-file packages

by choroba (Cardinal)
on Feb 12, 2014 at 15:46 UTC ( #1074638=note: print w/replies, xml ) Need Help??


in reply to Importing variables (not functions) from in-file packages

The error "... requires explicit package name" is a compile time error. It means Perl was not able to find where the variable was declared when compiling the script. Just put all the packages before the main package and everything will work.
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re: Importing variables (not functions) from in-file packages

Replies are listed 'Best First'.
Re^2: Importing variables (not functions) from in-file packages
by puterboy (Scribe) on Feb 12, 2014 at 15:55 UTC
    Thanks. I hadn't realized (and perhaps still don't fully understand) the difference between compile time vs. run time errors for variables and functions. But now that I think of it, I suppose this is consistent with the fact that variables need to be declared ahead of usage (if using strict) while function definitions can follow their usage.

    Is there any analogy to the run-time "BEGIN" to tell the compiler to start (or branch elsewhere)?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (1)
As of 2023-06-03 04:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (6 votes). Check out past polls.

    Notices?