in reply to Re^3: basic question:how to print a reversed array from STDIN
in thread basic question:how to print a reversed array from STDIN

No - map returns a new list, so changing $_ makes little sense. Either use a foreach if you want to do an inplace modification of a list or return a fresh list and try to keep away from changing the list alias :)

Replies are listed 'Best First'.
Re^5: basic question:how to print a reversed array from STDIN
by holli (Abbot) on Dec 04, 2008 at 13:01 UTC
    Yes, if you take care about the list on the right hand side. But, consider this:
    map { s/^.//; } grep { /^[abc]/ } @somewords;


    holli, /regexed monk/

      Now I also cringe at the map in void context.

      There's also a lack of visual distinction between list generation and list transformation.

      s/^.// for grep { /^[abc]/ } @somewords;
        O, you guys are so kind and profound!
        Got it!
        Thank you!