in reply to Underscore in scalar name not in main package

You probably missed the caret symbol. Here is the relevant passage from perlvar:

In particular, the special ${^_XYZ} variables are always taken to be in package main, regardless of any package declarations presently in scope.

Note that this paragraph should be read as the last paragraph of the whole section "The Syntax of Variable Names ", as it provides additional information to important details in the preceding text. It definitely doesn't mean "If you want to introduce a global variable without a declaration, start its name with ^_!".

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Underscore in scalar name not in main package
by LanX (Saint) on May 09, 2026 at 11:20 UTC
    Hmm ... I've never seen anyone introducing ${^_globals} in his code.

    Probably because it's much easier and clearer to just use a namespace for $MyApp::globals ...

    But well this might be useful for machine translations, that's also why JS originally allowed the $ symbol anywhere in variable identifiers.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery