Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Replacing values in an array

by eyepopslikeamosquito (Canon)
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 examining the Monastery: (7)
As of 2014-12-22 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (115 votes), past polls