# trie1 - use makeregex to construct a trie, then iterate through a # text finding all matches, # (note: make regex places a question mark after ther last character # if the word occurs both with and without it, e.g. "arm" and "arms" # gives "arms?" the question mark indicating that the s occurs zero or # more times. #regex: (a(nkles?|pron|rms?|ttired?)|b(a(ck|ld|re|ubles?)|e(a(r(d|ing) use MakeRegex; use Data::Dumper; $Data::Dumper::Indent = 0; @strlst = qw(ankles ankle apron arm arms attired back bald bare baubles bauble beard bearing); my($regex) = MakeRegex::make_regex(@strlst); print "regex: $regex\n\n\n"; @text = ; $text = join(" ",@text); $text =~ s/\n/ /g; $text =~ /($regex)/gi; $word = $1; while ($after = pos($text)) { print "($word,$after),"; $text =~ /($regex)/gi; $word = $1; } exit; __DATA__ her arms were bare he shaved his beard they held him by the ankles he was nearly bald she tied her apron strings his arms were huge he was attired in his Sunday best her head was adorned with little baubles he lost his bearing for a moment his back had scars all over it