in reply to Adding formatting to a string

You could simplify your own snippet somewhat:

$string = join '-', unpack 'A4 A*', $string;