in reply to sorting question
note further that cmp does NOT work for numerics, or look for yourself what is going wrong :) you need the <=> operator to do numeric sorting in this way.use strict; use warnings; use constant FIRST_FIELD => 1; use constant SECOND_FIELD => 2; use constant THIRD_FIELD => 3; my $str = ""; { local $/; $str = <DATA>; } $str = join "\n", map { $_->[0] } sort {$a->[THIRD_FIELD] cmp $b->[THIRD_FIELD] } map { [$_, split('\|', $_)] } split(/\n/, $str); print $str; __DATA__ xyz4|1026|CR xyz3|3461|CR dert5|3251|PR rtyaq|251|PR dbca|583|PR xxxt|360|CR
|
|---|