Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Solved: map on array reference

by kcott (Archbishop)
on Feb 16, 2016 at 09:55 UTC ( [id://1155347]=note: print w/replies, xml ) Need Help??


in reply to Solved: map on array reference

G'day natxo,

I see you've marked this as "Solved"; however, I thought I'd point out that, because map aliases $_ to each element of the list, you can do your substitution in-place. E.g.

$ perl -wE 'my $x = [qw{ab ac ad}]; say "@$x"; map { s/a/z/ } @$x; say + "@$x"' ab ac ad zb zc zd

— Ken

Log In?
Username:
Password:

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

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

    No recent polls found