Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Requires explicit package name

by Narveson (Chaplain)
on Nov 28, 2008 at 06:10 UTC ( [id://726525]=note: print w/replies, xml ) Need Help??


in reply to Requires explicit package name

"Requires explicit package name" is the error message you get under strict when you have failed to declare a variable. I shared your confusion the first time I saw this message. The remedy is not to supply a package name, but to declare the variable with my.

Replies are listed 'Best First'.
Re^2: Requires explicit package name
by ikegami (Patriarch) on Nov 28, 2008 at 06:59 UTC
    The error is indeed misleading. use diagnostics; gives better info, fortunately.
Re^2: Requires explicit package name
by sgt (Deacon) on Nov 28, 2008 at 22:18 UTC

    so maybe the warning should be changed and spelled

     var foobar needs explicit my or possibly (in rare cases) an our (or use vars) declaration or explicit pkg qualification like $pkg::foobar cheers --stephan
Re^2: Requires explicit package name
by Anonymous Monk on Nov 28, 2008 at 18:59 UTC
    Supplying a package name *is* a valid way to remedy this problem.
    use strict; $::some_var = "some value"; print $::some_var;
    Works fine.
      So does
      no strict; $some_var = "some value"; print $some_var;

      Would we sincerely recommend either method of silencing the error messages in the original post?

        No, I wouldn't :)
        I was merely trying to point out that the problem could be fixed by following the suggestion made in the error message, not that it necessarily was the best option ;)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found