in reply to Re: Auto linking to words in a text file
in thread Auto linking to words in a text file

You probably want to take one additional step and sort each of the keys by length, doing the longest first. This would allow you to catch a link to "foo bar" as well as individual links to "foo" and "bar" without getting inconsistent results.
foreach (sort { length($b) <=> length($a) } keys %keywords) { ... }