in reply to Better way of matching

Seems more like a matter of taste to me, whether you prefer a hash of subs or the ternary operator to your original elsif cascade.

OTOH using warnings with your code, perl would comment on your using one-element hash slices instead of array element references.

Also the OP could use another pair of <code> tags, since the links to node 2 and 4 are interesting, but somewhat OT. ;-)