in reply to Re: Word Evaluation
in thread Word Evaluation

Probably better check for word boundaries around the word, as they will also match the beginning and end of string;

next if $word=~/\b$w\b/;

Replies are listed 'Best First'.
Re: Re: Re: Word Evaluation
by integral (Hermit) on Jan 29, 2003 at 19:57 UTC
    Or you can use the slightly more longwinded form using alternations that allows $w to start with non-work characters (\b looks at the change between \W to \w not \s and \S):
    next if $word =~ /(^|\s)$w(\s|$)/;

    --
    integral, resident of freenode's #perl