use strict; use warnings; use HTML::TreeBuilder; my $html; $html .= $_ while ; my $Tree = HTML::TreeBuilder->new (); $Tree->parse ($html); $Tree->eof (); my %Words; ++$Words{$_} foreach (split (" ", $Tree->as_text ())); my @WordPos; my $Key; foreach $Key (keys %Words) { pos ($html) = 0; while ($html =~ />[^<]*?(\b$Key\b).*?[<\$]/gis) { push @WordPos, [$Key, $-[1]]; } } print join "\n", map {ref $_ ? join ' starts at ', @$_ : $_} @WordPos; __DATA__

This is my text. I hope you like it! img src, please don't munt me.
Would you like to see my Monkey?
oh and this too!