in reply to complex sort

I haven't taken the time to actually download and run this code, but it looks pretty good to me. A few suggestions:

--
g r i n d e r
just another bofh

print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u';

Replies are listed 'Best First'.
Re: Re: complex sort
by Juerd (Abbot) on Dec 25, 2001 at 03:15 UTC
    You can chomp <DATA> straight away before passing it to the sort routine. [...]
    [...]
    sort part_sort chomp <DATA>;
    <DATA> is immutable, so you cannot chomp it (chomp actually tries to modify what it gets - it returns the number of removed characters, not a list of chomped strings).

    #!/usr/bin/perl print chomp <DATA>; __DATA__ This piece of code will trigger the following compilation error: Can't modify <HANDLE> in chomp at - line 2, near "<DATA>;" Execution of test aborted due to compilation errors.

    2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$