testing testing... perl question

Cristina Nunes nunes.cristina at gmail.com
Mon Aug 13 12:04:35 BST 2007

On 8/13/07, Aidan Samuel <aidan.samuel at gmail.com> wrote:
> Hello everyone, I'm new here.
> Is it ok to ask a perl question?
> perl -e '@a = (1..5); print sort $a <=> $b, @a;'
> 012345

I think the "0" is the result of the sort $a <=> $b operation.
The rest is the print for an ARRAY.

> perl -e '@a = (1..5); print sort {$a <=> $b} @a;'
> 12345

This is the correct way to do it.

> When using map and grep I tend to leave off the curly braces and just
> use a comma, but if I try this with sort, I get these odd results.
> Thanks!
> Aidan.

<Alanna> Saying that Java is nice because it works on all OS's is like
saying that anal sex is nice because it works on all genders

More information about the london.pm mailing list