miketosh has asked for the wisdom of the Perl Monks concerning the following question:
I'm looking for a simple way to output the escaped-values of certain control characters, such as carriage return and line feed.
Code:My Desired output for the above code would be:my $string = "1\r\n 2 \n"; while ($string = /(.)/g) { print "Encountered character: $1\n"; }
Are there any known ways to get those values converted?Encountered character: 1 Encountered character: \r Encountered character: \n Encountered character: \s Encountered character: 2 Encountered character: \s Encountered character: \n
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Printing escaped values of control characters
by Eliya (Vicar) on Aug 02, 2011 at 15:40 UTC | |
|
Re: Printing escaped values of control characters
by Jim (Curate) on Aug 02, 2011 at 15:41 UTC | |
|
Re: Printing escaped values of control characters
by johngg (Canon) on Aug 02, 2011 at 22:44 UTC | |
|
Re: Printing escaped values of control characters
by perl5ever (Pilgrim) on Aug 02, 2011 at 20:17 UTC |