$text = "Hello\nWorld\n"; for (split//,$text) { printf "\%03o\n", ord $_; } $text =~ s/\012/\n\n\n/; print $text;