in reply to Re^2: What is the scope of $_?
in thread What is the scope of $_?

You are correct. I was under the impression that a reference to @_ behaved differently than a reference to another localized array, once the localization went out of scope.

But the following example appears to show they behave the same...

use strict; use Data::Dumper; our @X; my ($underscore, $scissors); @_ = (1..3); @X = (1..3); sub foo { local @X = (4..6); $underscore = \@_; $scissors = \@X; } foo(4..6); print Dumper($underscore, $scissors);

So (like $_) @_ is just a global array that gets localized by certain control structures. (In particular, sub.)

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'