in reply to EOF character

Try this:

print $fh chr 4;

Note, not tested, but I lifted the ASCII code for ^d from here: HTH. Also assumes you want to print to a filehandle $fh. If your filehandle is named differently, adjust to suit.

s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)