One thing to add about backreferencing, it's called an "NP-Complete" programming problems, which basically means, it is slow as hell. Therefore, if you can avoid using it (such as when you said you could just use $left $right and $mid) then you definately should.