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

NAME

Tree::Suffix - Perl interface to the libstree library

SYNOPSIS

  use Tree::Suffix;

  $tree = Tree::Suffix->new;
  $tree = Tree::Suffix->new(@strings);
  
  $tree->insert(@strings);
  $tree->remove(@strings);

  @lcs = $tree->lcs;
  @lcs = $tree->lcs($min_len, $max_len);
  @lcs = $tree->longest_common_substrings;

  @lrs = $tree->lrs;
  @lrs = $tree->lrs($min_len, $max_len);
  @lrs = $tree->longest_repeated_substrings;

  $num = $tree->strings;
  $num = $tree->nodes;

  $tree->clear;
  $tree->dump;

DESCRIPTION

The Tree::Suffix module provides an interface to the C library libstree, which implements generic suffix trees.

METHODS

$tree = Tree::Suffix->new
$tree = Tree::Suffix->new(@strings)

Creates a new Tree::Suffix object. The constructor will also accept a list of strings to be inserted into the tree.

$tree->insert(@strings)

Inserts the list of strings into the tree. Returns the number of successfully added strings.

$tree->remove(@strings)

Remove the list of strings from the tree.

$tree->lcs
$tree->lcs($min_len, $max_len)
$tree->longest_common_substrings

Returns a list of the longest common substrings. The minimum and maximum length of the considered substrings may also be specified.

$tree->lrs
$tree->lrs($min_len, $max_len)
$tree->longest_repeated_substrings

Returns a list of the longest repeated substrings. The minimum and maximum length of the considered substrings may also be specified.

$tree->strings

Returns the total number of strings in the tree.

$tree->nodes

Returns the total number of nodes in the tree.

$tree->clear

Removes all strings from the tree.

$tree->dump

Prints a representation of the tree to STDOUT.

EXAMPLE

To find the longest palindrome of a string:

  use Tree::Suffix;
  $str   = 'mississippi';
  $tree  = Tree::Suffix->new($str, scalar reverse $str);
  ($pal) = $tree->lcs;
  print "Longest palindrome: $pal\n";

This would print:

  Longest palindrome: ississi

SEE ALSO

libstree http://www.cl.cam.ac.uk/~cpk25/libstree/

SuffixTree

http://en.wikipedia.org/wiki/Suffix_tree

REQUESTS AND BUGS

Please report any bugs or feature requests to bug-tree-suffix at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tree-Suffix. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Tree::Suffix

You can also look for information at:

COPYRIGHT AND LICENSE

Copyright (C) 2006 gray <gray at cpan.org>, all rights reserved.

Copyright (C) 2003 Christian Kreibich <christian@whoop.org>

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

AUTHOR

gray, <gray at cpan.org>