next up previous contents index
Next: Iterative Pattern Matching Up: The XSB System Version Previous: Wildcard Matching and Globing   Contents   Index

Using Perl as a Pattern Matching and String Substitution Server

By Michael Kifer and Jin Yu

XSB has an efficient interface to the Perl interpreter, which allows XSB programs to use powerful Perl pattern matching capabilities. this interface is provided by the Perlmatch package. You need Perl 5.004 or later to be able to take advantage of this service.

This package is mostly superseded by the the more efficient POSIX Regmatch package described in the previous section. However, Perl regular expressions provide certain features not available in the Regmatch package, such as the ability to perform global replacements of matched susbstrings. Also, the Perlmatch package has a different programming interface, which is modeled after the interface provided by Perl itself. So, if you are a big fan of Perl, this package is for you.

The following discussion assumes that you are familiar with the syntax of Perl regular expressions and have a reasonably good idea about the capabilities of Perl matching and string substitution functions.

In the interactive mode, you must first load the Perlmatch package:

:- [perlmatch].

In a program, you must import the package predicates:


:- import bulk_match/3, get_match_result/2, try_match/2,
	  next_match/0, perl_substitute/3, load_perl/0, unload_perl/0
   from perlmatch.



Subsections
next up previous contents index
Next: Iterative Pattern Matching Up: The XSB System Version Previous: Wildcard Matching and Globing   Contents   Index
Baoqiu Cui
2000-04-23