A few pretty much orthogonal bits.
- Order the list of surnames by frequency, commonest first.
- Think about index. The surnames are fixed strings.
- @foo = substr( $_, $tart, $offset) =~ /$re/; has a lot to recommend it.
- The m//sg form suggests you are slurping the file. Unless the records are messy, it's often better to process each record as it's read.
- Benchmark. Regex and search code performance is subject to subtlety, and small things can make a big difference.
After Compline,
Zaxo