[plug] [Perl] sorting arrays based on scalar value - Golf any one?

Anthony J. Breeds-Taurima tony at cantech.net.au
Mon Nov 18 16:33:18 WST 2002


On Mon, 18 Nov 2002, Matthew Robinson wrote:

> I've just tested it for you and it still doesn't work ;)  I think the 
> fact that -p is wrapping it all in a while(<>) { ... } loop and then you 
> are sucking the contents of <> into the sort is confusing perl and 
> causing it to stop dead waiting for more input.

Yup you're dead right.

If you wnat to contents in a serperate file then do:

#!/usr/bin/perl -i~                 3
print sort{$b<=>$a}<>              21
                                   --
                                   24
                                   --

I haven't tested this at all.

Yours Tony

   Jan 22-25 2003           Linux.Conf.AU            http://linux.conf.au/
		  The Australian Linux Technical Conference!



More information about the plug mailing list