<?xml version="1.0" encoding="windows-1252"?>
<node id="1005751" title="Re^3: What is the scope of $_?" created="2012-11-26 14:35:03" updated="2012-11-26 14:35:03">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;You are correct. I was under the impression that a reference to &lt;c&gt;@_&lt;/c&gt; behaved differently than a reference to another localized array, once the localization went out of scope.&lt;/p&gt;

&lt;p&gt;But the following example appears to show they behave the same...&lt;/p&gt;

&lt;code&gt;
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);
&lt;/code&gt;

&lt;p&gt;So (like &lt;c&gt;$_&lt;/c&gt;) &lt;c&gt;@_&lt;/c&gt; is just a global array that gets localized by certain control structures. (In particular, &lt;c&gt;sub&lt;/c&gt;.)&lt;/p&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;
&lt;tt&gt;perl -E'sub Monkey::do{say$_,for@_,do{($monkey=&amp;#x5B;caller(0)]-&gt;&amp;#x5B;3])=~s{::}{ }and$monkey}}"Monkey say"-&gt;Monkey::do'
&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1005679</field>
<field name="parent_node">
1005740</field>
</data>
</node>
