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

Re: modify list through grep

by mickeyn (Priest)
on Nov 26, 2006 at 16:01 UTC ( #586118=note: print w/ replies, xml ) Need Help??


in reply to modify list through grep

the "aliases" are relevant when you work on a list returned by grep and not on an array that was created using this list.
(unless, of course the original array contained references which will still refer to the same vars/arrays/hashes)

example (here map works on the list returned by grep before it's assigned to an array):

@l = ( "a", "b", "c" ); @m = map {s/a/z/} grep /a/, @l; print @l;
will print "zbc"

Enjoy,
-- Mickey


Comment on Re: modify list through grep
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2014-09-23 18:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (234 votes), past polls