The function ascii_format() receives a string and returns the same string with white space characters being made visible, e.g. “abc<CR><LF>”.
sub ascii_format { my ($argin) = @_; my $argout = ""; foreach my $i ( 0 .. (length($argin) - 1)) { my $let = substr( $argin, $i, 1); my $dec = unpack( "C", $let); if( $dec < 32) { if( $dec == 10) { $argout .= "<LF>"; } elsif( $dec == 13) { $argout .= "<CR>"; } else { $argout .= "<$dec>"; } } else { $argout .= $let; } } return $argout; }