Hi bash,
Only for debugging So data should be human readable.
I think that's a tricky situation, because if you're debugging, it may be important to be able to see the differences between, for example, various Unicode whitespace characters. I suspect you only want to prevent certain characters from being escaped? That means you'd have to pick and choose.
Personally I don't find Data::Printer's dependency tree to be too bad. But just in case you're looking for something else, it might be possible to roll your own with Data::Dump::Filtered:
use warnings;
use strict;
use open qw/:std :utf8/;
my $str = "\$\x{2142}\x{1D1A}\x{018E}\x{0500}\x{2003}\"";
use Data::Dump 'pp';
use Data::Dump::Filtered qw/add_dump_filter/;
add_dump_filter( sub {
my ($ctx, $objref) = @_;
if ($ctx->is_scalar) {
#TODO: this doesn't escape, not really that great!
return { dump => "\"$$objref\"" };
}
return; # normal dumping
} );
print '$str=',pp($str),";\n";
Hope this helps, -- Hauke D
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|