The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Prolog::Utility::FromPerl - utility function to convert perl data structures to prolog terms

VERSION

This document describes Prolog::Utility::FromPerl version 1.0.2

SYNOPSIS

    use Prolog::Utility::FromPerl;

    my $h = { foo => 1, bar => [2,3], baz => { a => 123 } };

    my $t = prolog_term('wtf',$h);

    say $t; # wtf(bar(2,3), baz(a(123)), foo(1))  

    my $sort_hash = { abc => 1, xyz => 2, '_SORT' => ['xyz','abc'] };

    my $sorted_term = prolog_term('somefact',$sort_hash);

    say $sorted_term; # somefact(xyz(2),abc(1))

    my $functor=prolog_term('foo',1,2,3,'bar');

    say $functor; # foo(1,2,3,'bar')

    my $chained_term = chain_terms(prolog_term('foo',1),prolog_term('bar',2));

    say $chained_term; # foo(1),bar(2).

    my $type=prolog_term('type','bigserial');

    my $name=prolog_term('name','id');

    my $nullstatus=prolog_term('status','NOT NULL');

    my $column=prolog_term('column',$name,$type,$nullstatus);

    my $tablename=prolog_term('name','deal_reservation');

    my $columnlist = prolog_list($column);

    my $columns = prolog_term('columns',$columnlist);

    my $table=prolog_term('table',$name,$columns);

    say $table;
  
  

DESCRIPTION

    This module provides utility functions for converting perl data 
    structures to prolog terms.  Its main use case is for generating 
    prolog facts that will be written to a file for consulting by prolog.

INTERFACE

prolog_term given a name, and a data structure, return a prolog term
printable_prolog prepare a prolog term for printing by appending a period at the end of the term.
chain_terms given an array or array reference of terms, join them by commas and append a final period to them.
prolog_hash given a hash or hash reference, convert each key value pair to a prolog term. The keys will be sorted by the sort function in order to maintain a consistent order due to hash randomization in perl 5.18. If you provide a key named _SORT with a value that is an array reference containing the other keys in the order you wish them to appear, they will be sorted by this order. The _SORT key itself will not appear in the output.
prolog_list given an array or array reference, convert to a prolog list

DIAGNOSTICS

unsupported reference

prolog_term can only convert scalar, array, or hash references

CONFIGURATION AND ENVIRONMENT

Prolog::Utility::FromPerl requires no configuration files or environment variables.

DEPENDENCIES

    Regex::Common
    Test::More
    version

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to bug-prolog-utility-fromperl@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR

Tyson Maly <tvmaly@cpan.org>

LICENCE AND COPYRIGHT

Copyright (c) 2013, Tyson Maly <tvmaly@cpan.org>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.