Unfortunately I'm not sure that this will be able to work with my patterns. I'll be reading the patterns in from another file, not creating them myself, and they could be arbitrarily complex - not necessarily a simple word to match like 'foo' which means I don't think the matching text will be much good for a key to a hash. Sorry if I misled you on that point in my original post - I should have given a better example of the pattenrs.