in reply to print out

Before you test it, remove the spaces:
$msg =~ tr/ //d;

Caution: Contents may have been coded under pressure.