#!/usr/bin/perl use strict; use warnings; no warnings qw /syntax/; use Getopt::Long; my ($show_ends, $show_tabs, $show_nonprinting); GetOptions ("A|show-all" => sub {$show_ends = 1; $show_tabs = 1; $show_nonprinting = 1}, "e" => sub {$show_ends = 1; $show_nonprinting = 1}, "E|show-ends" => sub {$show_ends = 1}, "t" => sub {$show_tabs = 1; $show_nonprinting = 1}, "T|show-tabs" => sub {$show_tabs = 1}, "v|show-nonprinting" => sub {$show_nonprinting = 1}, ); while (<>) { chomp; s/([\x80-\xFF])/"M-" . chr (ord ($1) - 0x80)/eg if $show_nonprinting; s/([\x00-\x08])/"^" . chr (ord ($1) + 0x40)/eg if $show_nonprinting; s/([\x0A-\x1F])/"^" . chr (ord ($1) + 0x40)/eg if $show_nonprinting; s/\x7F/^?/g if $show_nonprinting; s/\x09/^I/g if $show_tabs; s/$/\$/ if $show_ends; print "$_\n"; } __END__