I started using a hash but then found some errors can match multiple patterns so I needed to keep the map in order to be sure what would match where. That was the hack (ugly replacement of hash with munged array) that got me into this problem. The code that worked fine with the hash now got clobbered by some dodgy use of regexp.
thanks for the suggestion anyway.