in reply to Another puzzled RegEx Problem.

Like the error message says, a limitation of (?<=re) and (?<!re) is that re must only match expressions of a known, fixed length. That means you can use ?, *, +, etc in re. Basically, the regexp engine needs to know how many characters to look back.

Some alternatives:

$d =~ s/(\d\d)(?=\d)/$1-/g;
1 while $d =~ s/(?<=\d\d)(?=\d)/-/;
$d = reverse($d); $d =~ s/(?<=\d)(?=(\d\d)+$)/-/g; $d = reverse($d);

Update: Added solutions.