my $input="123+45"; for ($input) { tr/ +/+ /; $_= join "+ +", split; tr/ +/+ /; } print $input;