App-psort
view release on metacpan or search on metacpan
=head1 SYNOPSIS
psort [OPTION]... [FILE]...
=head1 DESCRIPTION
A perl-enhanced variant of L<sort(1)>. The specified files (or
standard input) are written sorted to standard output.
By default, sorting is done using perl's L<< cmp|perlop/cmp >>
operator, without any use of locales or encodings.
=head2 OPTIONS
=over
=item -b, --ignore-leading-blanks
Ignore any whitespace character (C<\s>) at the beginning of a line.
=item -c, --check
the variables C<$a> and C<$b> are available.
Examples
=over
=item * Reimplementing the C<-n> switch:
-C '$a <=> $b'
=item * Using locale comparisons:
-C 'use locale; $a cmp $b'
=back
Note that it is possible to put C<BEGIN { ... }> blocks into the
comparison function.
=item -e, --field-function
Extract the sorting field (or the sorting key) using a custom perl
function. For your convenience, the enclosing "sub {" and "}" must not
By default psort warns if a custom field function or rx returns an
undefined value. These warnings may be suppressed with this option.
=back
=head2 COMPATIBILITY
Some options found in GNU/POSIX sort are also available in psort. But
no attempt was done to make psort compatible to GNU/POSIX sort.
Especially there's no locale support (but see above how to C<use
locale> in the C<-C> option). There's also no encoding support (though
it probably can be emulated by using C<<Encode/decode> in the C<-e> or
C<-C> option).
=head2 TODO
Here are some ideas for future options:
=over
=item C<--encoding>
psort -MUnicode::Collate -MEncode=decode -e 'decode("utf-8", $_)' -C 'BEGIN { $Collator = Unicode::Collate->new } $Collator->cmp($a,$b)'
=item Sort specific columns (<-k>)
Currently one has to use something like the following to sort by
columns:
psort -e '@F=split; $F[...]'
=item C<--locale>
Specify a locale.
=item C<-o>
Instead writing to standard output, write to the specified output file.
=item C<-m>
Assume that input files are already sorted.
=item C<-u>
( run in 1.313 second using v1.01-cache-2.11-cpan-ceb78f64989 )