in reply to Re^3: Fine tuning a reg exp
in thread Fine tuning a reg exp

Marshall, thanks for that nice code. How would I extend it so that to each record I can apply various tags to identify elements, so for each surname something like this:
s/^(([A-Z]+\s[A-Z]+,|[A-Z]+-[A-Z]+,|[A-Z]+\s[A-Z]+\s[A-Z]+,)|([A-Z]+,) +)/\<surname\>$1\<\/surname\>/;
Would I put this in the my @records bit as a map, or in the foreach (@records) bit? I would like to apply to each record a range of markup tags, but just not sure how I tell Perl to do this. I did try putting the above regexp sub as a map in the my @records bit but it does always work.