Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

57 lines (41 sloc) 0.676 kB
#!/usr/bin/perl -w
use strict;
my %sort =
(
B => \&backwards,
F => \&forwards
);
sub backwards
{
return $b cmp $a;
}
sub forwards
{
return $a cmp $b;
}
sub GetAlgorithm
{
my ($alg) = @_;
return $sort{$alg};
}
my @list = qw( a d e c g );
# my $alg = GetAlgorithm(('B', 'F')[int(rand(2))]);
my $alg = GetAlgorithm(('B', 'F')[0]);
@list = sort {&{$alg}} @list;
use Data::Dumper;
print STDERR Dumper(\@list);
package Failure;
sub fail
{
my @x = 1 .. 5;
my @y = sort { Failure->xyz( $a, $b ) } @x;
}
sub xyz
{
my $self = shift;
my ($a, $b) = @_;
$a <=> $b;
}
package main;
my @l = Failure->fail;
print STDERR Dumper(\@l);
Jump to Line
Something went wrong with that request. Please try again.