Example 9-4. examples/subroutines/sort_with_function.pl #!/usr/bin/perl
use strict;
use warnings;
my @data = (23, 1, 12, 3, 48);
my @sorted = sort by_number @data;
print "@data\n";
print "@sorted\n";
sub by_number {
return $a <=> $b;
}
If you are interested in on-site trainings by the author, please
contact me directly.
|