in reply to Optimizing a regex

Well, one way to optimise it would be to add
last if ($pt ne "" && $pc eq "");
That will get you out of the loop once you've found what you're looking for. (cue U2)
You also want to use eq instead of == if you're testing for "". This code prints hello.
$ha = "hi"; if ($ha == "") { print "hello\n"; }
If doing numeric comparisons, strings with no digits are equal to 0. So $ha equals 0 as does "". If you turn on warnings this will be pointed out. Now if no-one else has done your regex, I'll look at that more closely.