in reply to Matching problem
Try:
chomp( my $content = <INPUT> ); # to get rid of a trailing linebreak.
if ( $content =~ m/^\Q$searchword\E$/ ) # escape/quote funny characters in $searchword.
Update:
The anchors ^ and $ match beginning and end of the string. I understand that's what you want.
If you want to match the word inside a longer string, go for ccn's proposal using the word boundary \b instead of the anchors.
See either perldoc perlrequick, perldoc perlre or perldoc perlretut
Cheers, Sören
|
|---|