in reply to array sorting

my @animals = ("frog", "toad", "snake", "grasshopper", "bird"); print join (' ', sort @animals), "\n"; # or print qq{@{[ sort @animals ]}}, "\n"; # etc...

Replies are listed 'Best First'.
Re: Re: array sorting
by Anonymous Monk on Jan 29, 2004 at 09:58 UTC

    Tsk, tsk.

    Your code had only the reference to join when you posted, and after Caron showed the @{[ sort @animals ]} idiom, then you added that as well.

    Not good, Roger. At least, acknowledge that it was an update. Don't learn from somebody else's worst practices.

    The PM Observer

      Damn, I thought nobody saw that. ;-)

      You must have seen my initial post within the first minute I posted, 'cause I updated my post before davido made his first post.

      I hesitated to include the interpolated hash slice solution initially because I think of it as an obfuscated over-kill, but included in my update for completeness. I was going to add the print "$_ " for @animals solution too but stopped short because that solution will print an additional blank space after the last element in the array, which I consider as not a proper solution.

      So the answer is -
      yes, I admit I have updated without labelling it as an update.
      no, I didn't see Caron's post before my update.