Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to substitute the elements in an array without changing the original array. - map

by imp (Priest)
on Dec 01, 2006 at 05:51 UTC ( [id://587129]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @source = (1,2,3,4);
    my @dest = map { $_ * 2 } @source;
    ...
    #Output:
    #1 2 3 4
    #2 4 6 8
    
  2. or download this
    my @source = ('bob', 'joe');
    my @dest = map { $_ eq 'bob' ? ucfirst($_) : $_ } @source;
    ...
    #Output:
    #bob joe
    #Bob joe
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-03-29 11:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found