Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Perl For loops

by naikonta (Curate)
on Jul 04, 2007 at 01:48 UTC ( [id://624816]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl For loops
in thread Perl For loops

map returns a new list, whereas for allows modification of an existing one
It sounds like contracdicting although, perhaps, you didn't mean it. The map operator allows modification as well since $_ would be a reference to the corresponding elements of existing array.
$ perl -wle 'my @ar = qw(one two three); print "@ar"; my @new = map { +$_ = uc } @ar; print "@new"; print "@ar"' one two three ONE TWO THREE ONE TWO THREE

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Replies are listed 'Best First'.
Re^3: Perl For loops
by cdarke (Prior) on Jul 04, 2007 at 10:42 UTC
    True. Apologies.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-25 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found