in reply to Re^3: Logic for importing and strict vars?
in thread Logic for importing and strict vars?

think it is likely that the first form is not a valid trigger to 'declare' $x and the latter form is valid

Note that what B::Deparse is doing is taking the compiled optree and turning that back into Perl code. It's not perfect, there are sometimes ambiguities about which Perl code produced which op, so it's not always a reliable 1:1 representation of the optree or the original code. It seems to me that this might be one of those cases where it might not be the best tool.

But I am still confused though 'what' declared means. Is it turned into a lexical scoped package variable, or is it similar to 'use vars'?

It's too late here for me to go reference hunting in the docs, but as far as I remember right now package variables aren't really declared* - they just have symbol table entries, and what vars does it set up the symbol table entry during compile time (and from another package, as we've learned that's important), such that strict vars considers it "declared". In other words, when compiling package X { *::x=\$a }; $x++;, the assignment to the glob *::x hasn't happened yet by the time $x++; is compiled, so it's an error, but in package X { BEGIN { *::x=\$a } }; $x++;, the assignment to the glob *::x has happened by the time the compiler sees $x++;, and that's considered ok. And yes, there isn't really a formal declaration like with my.

* I'm not counting our because it "makes a lexical alias to a package variable of the same name".

This line in 'use' documentation is not clear to me:"...which are effective through the end of the file..."

AFAICT the "which are effective through the end of the file" refers only to the immediately preceding "the current package" - the effect of a use vars applies to that package, regardless of whether that package spans multiple files.