From your language, you seem to be imagining your sequence of substitutions are working forward through the string, each substitution taking up where the last one left off. In fact, each substitution will apply to the entire string.
When you say "the position of the last replacement", what should happen if the previous substitution found nothing?
In a script, you can just do:
if ( s/\s\+\d\d\d\d\]// ) { $' =~ s/ /+/g }
but use of $' should be avoided in reusable code, since it can impact performance of other regular expressions. There, you'd need to do
if ( s/\s\+\d\d\d\d\]// ) { substr($_, $+[0]) =~ s/ /+/g }
but in either case, you need to make sure that the match or substitution you expect to have set $' or @+ actually succeeded.