in reply to Re^2: search for exact string
in thread search for exact string
That's possible - but has built-in problems.
for (@list){ ### This will not match 'String' at the end of the line print if /String\s/; }
Unless you have a really unusual requirement, the typical thing to do in these cases is to look for the string followed by (or, even more commonly, surrounded by) a boundary or boundaries. Note that these are zero-width assertions - unlike whitespace which actually requires a character:
for (@list){ print if /String\b/; }
This will match your string even if it's at the end of the line.
|
|---|