ewok ewok - 1 year ago 193
Perl Question

perl: show raw string, including special characters

I want to print out the raw text of a string, without interpolating special characters. So, for example, if my string is

, I want to print that, rather than


The string is stored in a variable, I'm not working with literals, so it's not just a matter of single-quote vs double-quote (I don't think). How can I do this?

mob mob
Answer Source

The right incantation of Data::Dumper will do this.

use Data::Dumper;
$Data::Dumper::Terse = 1;
$Data::Dumper::Useqq = 1;

$foo = "hello\nthere";
print Dumper $foo;         #  "hello\nthere"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download