Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: twig_print_outside_roots replaces " with &quote; and ' with '

by kcott (Archbishop)
on Nov 29, 2016 at 20:14 UTC ( [id://1176852]=note: print w/replies, xml ) Need Help??


in reply to twig_print_outside_roots replaces " with &quote; and ' with '

G'day Dimitar,

You can write a very simple function, to convert those (and other) entities back to their original characters, if that's what you need:

#!/usr/bin/env perl use strict; use warnings; { my %char_for_ent = qw{&quot; " &apos; ' &lt; < &gt; >}; my $re = qr/(?x: ( @{[ join '|', keys %char_for_ent ]} ) )/; sub ent2char { $_[0] =~ s/$re/$char_for_ent{$1}/g; $_[0] } } print "IN: ${_}OUT: ", ent2char($_) while <DATA>; __DATA__ I said, &quot;My name&apos;s Ken&quot;. <pre>Here&apos;s some &lt;em&gt;emphasis&lt;/em&gt;.</pre>

Output:

IN: I said, &quot;My name&apos;s Ken&quot;. OUT: I said, "My name's Ken". IN: <pre>Here&apos;s some &lt;em&gt;emphasis&lt;/em&gt;.</pre> OUT: <pre>Here's some <em>emphasis</em>.</pre>

I suspect there may be a CPAN module with this functionality. I don't know for certain: perhaps another monk does.

— Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1176852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-24 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found