Just create a lookup table for whatever characters you consider to be control characters (why is space a control char?):
my %escaped = ( "\n" => '\n', "\r" => '\r', " " => '\s', # ... ); my $string = "1\r\n 2 \n"; while ($string =~ /(.)/sg) { my $ch = $1; $ch = $escaped{$ch} if exists $escaped{$ch}; print "Encountered character: $ch\n"; }
In reply to Re: Printing escaped values of control characters
by Eliya
in thread Printing escaped values of control characters
by miketosh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |