use strict; use warnings; while (<DATA>) { if ($_ =~ m/\bGuinea\b/) { print "We have a match\n"; # m/\bGuinea\b$/ matches Guinea at end #m/^\bGuinea\b$/ matches Guinea at the beginning } else { print "We do not have a match\n"; } } __DATA__ Papua New Guinea I live in Guinea Guinea Bissau Equatorial Guinea
In reply to Matching a Word Exactly by GuiPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |