Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Replacing values in an array

by eyepopslikeamosquito (Chancellor)
on Jan 27, 2013 at 01:31 UTC ( #1015556=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
    my ( $n,  %h ) = -1;
    $_ = $h{$_} //= $n+=2 for @a;
    print Dumper \@a;
    
  2. or download this
    my ( $n,  %h ) = -1;
    $_ = $h{$_} //= $n+=2 for @a;
    
  3. or download this
    $_=$h{$_}//=$}+=2-!$}for@a;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015556]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2016-04-30 23:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW







    Results (441 votes). Check out past polls.