in reply to count words in a line

We build the regex from the word using \s* in between the letters.

my $word = "perlmonk"; my $re = join('\s*',$word =~ /\w/g); my $qre = qr/$re/; while (<DATA>) { my $count = () = /$qre/g; print "$count == $_"; } __DATA__ perlmonk perlmonk perlmonk perl m onk p erlmonk per lm onk per lm onk

Updated: actually answered question this time.

--
Steve Marvell