in reply to basic question:how to print a reversed array from STDIN

The reason why is what ikegami said. So try this:
@getnew=reverse(map { chomp; $_} <STDIN>);
or
chomp(@temp=<STDIN>); @getnew=reverse(@temp);
Whatever you like best. I prefer the first version.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: basic question:how to print a reversed array from STDIN
by oxone (Friar) on Dec 04, 2008 at 13:13 UTC
    I think this is neater:
    chomp(@getnew = reverse <STDIN>);
Re^2: basic question:how to print a reversed array from STDIN
by ikegami (Patriarch) on Dec 04, 2008 at 12:37 UTC
    I cringe when I see map or grep modify $_.
      I agree with you in regards to grep, but map? It's sole purpose is the modification of $_.


      holli, /regexed monk/

        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 :)