in reply to Re: Perl For loops
in thread Perl For loops
map returns a new list, whereas for allows modification of an existing oneIt 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 |