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";