in reply to Performance optimization question
What's the regular expression in question?
What's the code that uses this? A macro change is usually the way to go.
$#arr1 = -1; is totally useless seeing how @arr1 is overwritten on the next line.