- or download this
sub foo {
bar() or die "we failed";
...
};
die "it worked" if foo();
- or download this
sub foo {
my $c = shift;
...
};
foo( sub {die 'it worked'} ) || die "we failed\";
- or download this
/* frank and dean are male */
male(frank).
...
/* frank sang with judy, frank sang with dean */
sang_with(frank, judy).
sang_with(frank, dean).
- or download this
use Test::More 'no_plan';
...
ok(!$v2->bind($v1), 'cannot bind bound var');
ok( $v1->bind($v2), 'can bind unbound var');
is( $v1->value, "hello", ' to correct value');
- or download this
use strict;
use warnings;
...
my $self = shift;
$$self = \undef;
};
- or download this
sub unify {
my ($v1, $v2, $continuation) = @_;
...
};
return(0);
};
- or download this
male(frank).
male(dean).
- or download this
sub male {
my ($var, $continuation) = @_;
unify("frank", $var, $continuation);
unify("dean", $var, $continuation);
};
- or download this
sub male {
unify("frank", @_);
unify("dean", @_);
};
- or download this
# print out all the males
my $a = Var->new;
...
# is dean male
eval {male("dean", sub {Success->throw})};
print $@ ? "dean is male" : "dean is not male", "\n";
- or download this
sub female {
...
my ($var, $continuation) = @_;
female($var, sub {acts($var, $continuation)});
};
- or download this
# print out all of the actors
my $c = Var->new;
...
# is ella an actress
eval {actress("ella", sub {Success->throw})};
print $@ ? "ella is an actress" : "ella is not an actress", "\n";
- or download this
/* frank sang with judy, frank sang with dean */
sang_with(frank, judy).
sang_with(frank, dean).
- or download this
sub sang_with {
my ($p1, $p2, $continuation) = @_;
unify($p1, 'frank', sub {unify($p2, 'judy', $continuation)});
unify($p1, 'frank', sub {unify($p2, 'dean', $continuation)});
};
- or download this
sub unify_all {
my ($a, $b, $continuation) = @_;
...
};
return(0);
};
- or download this
sub sang_with {
my ($p1, $p2, $continuation) = @_;
unify_all(['frank', 'judy'], [$p1, $p2], $continuation);
unify_all(['frank', 'dean'], [$p1, $p2], $continuation);
};
- or download this
my $x = Var->new;
eval {
...
)
};
print "frank did sing with an actor\n" if $@;
- or download this
my $x = Var->new;
my $succeed = sub { Success->throw };
my $sang_with = sub { sang_with("frank", $x, $succeed) };
eval { actor($x, $sang_with) };
print "frank did sing with an actor\n" if $@;