|P is for Practical|
Re^3: perl substitue till found pattern in alineby rjt (Chaplain)
|on Dec 03, 2012 at 08:57 UTC||Need Help??|
Your code is slower by about a factor of 3:
Regarding readability, it will depend who you ask in this case. In my experience, I tend to find a simple regex easier to read than tearing apart and piecing a solution back together with split, s///, and join.
Lastly, in your code, replacing this:print join '-1', $left, $right;
... with this:print $left, '-1', $right;
... resulted in a 32% speed improvement before I/O on your solution (still ~2.2x slower than the straight regex) and puts the terms in their natural order, which is probably more readable than the strange use of join with a delimiter to concatenate three strings.
I hope this is useful feedback to your feedback!