http://qs1969.pair.com?node_id=726525


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