<?xml version="1.0" encoding="windows-1252"?>
<node id="1015556" title="Re^2: Replacing values in an array" created="2013-01-26 20:31:03" updated="2013-01-26 20:31:03">
<type id="11">
note</type>
<author id="176576">
eyepopslikeamosquito</author>
<data>
<field name="doctext">
&lt;P&gt;
Using for instead of [doc://map]:
&lt;CODE&gt;
use strict;
use warnings;
use Data::Dumper;
my @a = ("M94202", "M94150", "M94297", "M94150", "M94161", "M94161", "M94162");
my ( $n,  %h ) = -1;
$_ = $h{$_} //= $n+=2 for @a;
print Dumper \@a;
&lt;/CODE&gt;
&lt;/P&gt;

&lt;P&gt;
I suppose if you were playing golf, without use strict, you might write:
&lt;CODE&gt;
my ( $n,  %h ) = -1;
$_ = $h{$_} //= $n+=2 for @a;
&lt;/CODE&gt;
in one-line as:
&lt;CODE&gt;
$_=$h{$_}//=$}+=2-!$}for@a;
&lt;/CODE&gt;
(/me ducks)
&lt;/P&gt;
</field>
<field name="root_node">
1015541</field>
<field name="parent_node">
1015546</field>
</data>
</node>
