note
Athanasius
<blockquote>
<i>shift(@_) is a current $_</i>
</blockquote>
<p>No. Here is the skeleton of the opening of the <c>import</c> subroutine in [mod://Win32::TieRegistry]:</p>
<code>
sub import
{
my $pkg = shift(@_);
...
local( $_ );
while( @_ ) {
$_= shift(@_);
if( ... ) {
...
} elsif( ... ) {
...
...
} elsif( exists $_opt_subs{$_} ) {
...
$registry->$_( shift(@_) );
} elsif( ... ) {
...
</code>
<p>Each call to [doc://shift] removes another element from the head of the <c>@_</c> array, i.e., another argument from the list of those passed into <c>sub import</c>. So in the line:</p>
<code>
$registry->$_( shift(@_) );
</code>
<p>the variable <c>$_</c> holds the last argument to have been removed from <c>@_</c>; but the expression <c>shift(@_)</c> removes the <i>next</i> argument from <c>@_</c>. <c>$_</c> and <c>shift(@_)</c> will (most likely) have different values.</p>
<p><c>shift(@_)</c> does <i>not</i> reset the value of <c>$_</c>:</p>
<code>
17:43 >perl -wE "f(1, 2, 3); sub f { local($_) = shift(@_); my $c = shift(@_); say '$_ = ', $_; say '$c = ', $c; say '@_ = ', @_; }"
$_ = 1
$c = 2
@_ = 3
18:07 >
</code>
<p>Hope that helps,</p>
<div class="pmsig"><div class="pmsig-968231">
<p>
<table width="100%">
<tr>
<td align="left">
Athanasius <font color="#008000"><</font>[href://http://www.biblegateway.com/passage/?search=John%203:16&version=NLV|<font color="#008000">°</font>]<font color="#008000">(((><</font> <i>contra mundum</i>
</td>
<td align="right">
[href://http://translate.google.com.au/#la/en/Iustus%20alius%20egestas%20vitae%2C%20eros%20Piratica%2C|<b>Iustus alius egestas vitae, eros Piratica,</b>]
</td>
</tr>
</table>
</p>
</div></div>
1011960
1011960