In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/1cb246e8dcbc92bfdff3156b4963ab3a06f97534?hp=a9320c62d9034275ce0ce1fa301011823fbbe2a4>
- Log ----------------------------------------------------------------- commit 1cb246e8dcbc92bfdff3156b4963ab3a06f97534 Author: Rafael Garcia-Suarez <[email protected]> Date: Sun Jun 28 14:03:36 2009 +0200 Small pod/wording fixes ----------------------------------------------------------------------- Summary of changes: pod/perlfunc.pod | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 2169a44..884644e 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -5365,27 +5365,26 @@ Examples: use sort '_mergesort'; # note discouraging _ @new = sort { substr($a, 3, 5) cmp substr($b, 3, 5) } @old; +Warning: syntactical care is required when sorting the list returned from +a function. If you want to sort the list returned by the function call +C<find_records(@key)>, you can use: -Warning: Care is required when sorting the list returned from a function. - -If you want to sort returned by the function call: find_records(@key) then -you can use: @contact = sort { $a cmp $b } find_records @key; @contact = sort +find_records(@key); @contact = sort &find_records(@key); @contact = sort(find_records(@key)); If instead you want to sort the array @key with the comparison routine -find_records then you can use: +C<find_records()> then you can use: + @contact = sort { find_records() } @key; @contact = sort find_records(@key); @contact = sort(find_records @key); @contact = sort(find_records (@key)); - If you're using strict, you I<must not> declare $a and $b as lexicals. They are package globals. That means -if you're in the C<main> package and type +that if you're in the C<main> package and type @articles = sort {$b <=> $a} @files; -- Perl5 Master Repository
