The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Text::Context::Porter - Text::Context with inflection awareness


  use Text::Context::Porter;

  my $snippet = Text::Context::Porter->new($text, @keywords);

  $snippet->keywords("foo", "bar"); # In case you change your mind

  print $snippet->as_html;
  print $snippet->as_text;


Given a piece of text and some search terms, produces an object which locates the search terms in the message, extracts a reasonable-length string containing all the search terms, and optionally dumps the string out as HTML text with the search terms highlighted in bold.

However, unlike the ordinary Text::Context, this subclass is able to highlight terms in the document which are inflected variants of the search terms. For instance, searching for "testing" should highlight "test", "tested" and so on.


  Copyright (C) 2004,2006 Simon Cozens

You may use and redistribute this module under the same terms as Perl itself.