AI-Prolog
view release on metacpan or search on metacpan
bin/aiprolog view on Meta::CPAN
if (';' eq $key) {
print $OUT ";\n\n";
return 1;
}
print $OUT "\n\nYes\n" if $RESULTS;
return;
}
my $offset;
sub help {
$offset ||= tell DATA;
seek DATA, $offset, 0;
pod2usage({
-verbose => 2,
-input => \*DATA,
-exitval => 'NOEXIT',
});
}
__DATA__
=head1 NAME
aiprolog -- A simple Prolog shell using AI::Prolog.
=head1 SYNOPSIS
usage: aiprolog <optional prolog program name>
=head1 DESCRIPTION
lib/AI/Prolog/Article.pod view on Meta::CPAN
Now let's see the full program:
#!/usr/bin/perl
use strict;
use warnings;
use AI::Prolog;
my $prolog;
# If reading from DATA, we need a CHECK block to ensure that
# DATA is available by the time the constructor is called
CHECK {
$prolog = AI::Prolog->new( do { local $/; <DATA> } );
}
$prolog->query( 'father(WHO).' );
while ( my $results = $prolog->results ) {
print "@$results\n";
}
__DATA__
parent(sally, tom).
parent(bill, tom).
parent(tom, sue).
parent(alice, sue).
parent(sarah, tim).
male(bill).
male(tom).
male(tim).
( run in 1.296 second using v1.01-cache-2.11-cpan-140bd7fdf52 )