In article <005e01c1370a$1a1fd920$f95314ac@04778-9>,
[EMAIL PROTECTED] (McGregory Pinto) wrote:
> How i do a sort, like "sort -k3,5 -d" "" command, in a file using Perl.
you can use a Schwartzian Transform with the sort key being
the part of the string that you extract with substr:
my @sorted = map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [ $_, substr($_, 2, 3) ] }
@lines;
for the full details see the various explanation about how
an ST works:
http://www.google.com/search?q=schwartzian+transform
--
brian d foy <[EMAIL PROTECTED]> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]