in reply to Re: can't find mistake. lost in references
in thread can't find mistake. lost in references

you are even referring to two different @_ arrays explicitly. The one that passes the parameters into the subroutine and the global one that you use to store your data.

:) There is only one @_ and it is "super global" that is anytime you write @_ its always @_ (its always @main::_ ) regardless of package

Symbol isn't exactly authoritative but it does show this

$ perl -MSymbol=qualify -le " print qualify($_,q/Fooo/) for qw/ ARGV S +TDOUT STDERR _ AHOY / main::ARGV main::STDOUT main::STDERR main::_ Fooo::AHOY

pervar says: Perl identifiers that begin with digits, control characters, or punctuation characters are exempt from the effects of the package declaration and are always forced to be in package main ; they are also exempt from strict 'vars' errors. A few other names are also exempt in these ways: ENV STDIN INC STDOUT ARGV STDERR ARGVOUT SIG

  • Comment on Re^2: can't find mistake. lost in references (super global @_ is always in main @main::_ $main::_ )
  • Download Code

Replies are listed 'Best First'.
Re^3: can't find mistake. lost in references (super global @_ is always in main @main::_ $main::_ )
by hdb (Monsignor) on Mar 14, 2015 at 18:25 UTC

    Thanks for the clarification! I should have said something like: referring to @_ as if there were two of them...

Re^3: can't find mistake. lost in references (super global @_ is always in main @main::_ $main::_ )
by ikegami (Patriarch) on Mar 16, 2015 at 00:16 UTC

    He'd have the same problem even if @_ wasn't a "super global". The actual problem is that sub calls localize @_ as part of placing the arguments in it.

    PS - There can be more than one @_ in every package. It's just that unqualified @_ always refers to @::_. You can access package Foo's @_ using @Foo::_.