in reply to Perl For loops

Why? What are you trying to achieve?
It would help for readability if you used code tags.
map returns a new list, whereas for allows modification of an existing one. You need to take the input list in your map and use that as the for list. You then need to push your result onto the output array.
But if your code works, then why rewrite it to use for?

Replies are listed 'Best First'.
Re^2: Perl For loops
by naikonta (Curate) on Jul 04, 2007 at 01:48 UTC
    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!

      True. Apologies.