Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by perladdict (Chaplain)
on Dec 01, 2006 at 08:43 UTC ( #587142=note: print w/ replies, xml ) Need Help??


in reply to How to substitute the elements in an array without changing the original array.

hey, if u r trying to replace the strings by using s///operator,the below code will wok fine.

#!/usr/bin/perl -w @a=("sedam","medam","kadam","sadam"); for(@b=@a) { s/dam/lam/; } print "@b\n"; print "@a";


Comment on Re: How to substitute the elements in an array without changing the original array.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2015-07-29 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls