/usr/share/doc/libclass-multimethods-perl/examples/demo.ambig.pl is in libclass-multimethods-perl 1.701-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #!/usr/bin/env perl -w
use 5.005;
use Class::Multimethods;
multimethod put => (RoundPeg,Hole) => sub
{
print "a round peg in any old hole\n";
};
multimethod put => (Peg,SquareHole) => sub
{
print "any old peg in a square hole\n";
};
multimethod put => (Peg,Hole) => sub
{
print "any old peg in any old hole\n";
};
# resolve_ambiguous put
# => sub
# {
# print "can't put a ", ref($_[0]),
# " into a ", ref($_[1]), "\n";
# };
# resolve_no_match put
# => sub
# {
# print "huh????\n";
# };
# OR ELSE:
#
# resolve_ambiguous "put" => (Peg,Hole);
#
# resolve_no_match "put" => ('*','*'); # Note this will still fail unless
# this variant is actually defined
# when &put is called.
@RoundPeg::ISA = qw{ Peg };
$peg = bless {}, Peg;
$roundpeg = bless {}, RoundPeg;
@SquareHole::ISA = qw{ Hole };
$hole = bless {}, Hole;
$squarehole = bless {}, SquareHole;
eval { put($peg, $hole) } or print "ERROR: $@\n";
eval { put($roundpeg, $hole) } or print "ERROR: $@\n";
eval { put($peg, $squarehole) } or print "ERROR: $@\n";
eval { put($roundpeg, $squarehole) } or print "ERROR: $@\n";
eval { put(2,3) } or print "ERROR: $@\n";
Class::Multimethods::analyse(put=>[RoundPeg,SquareHole]);
|