1 2 3 4 5 6 7 8
# set text $text = q~\u2018Jihadism\u2019~; # replace \uXYZ with html entity &#xXYZ; $text =~ s/\\u(\d+)/&#x$1;/g; # print text with html entities say $text;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
use HTTP::Tiny qw(); use JSON::MaybeXS qw(decode_json); use Text::Xslate qw(); my $response = HTTP::Tiny->new->get('https://api.crossref.org/works/10.1177/0974928419874548'); die($response->{status}, $response->{reason}) unless $response->{success}; my $template = Text::Xslate->new; my $abstract = decode_json($response->{content})->{message}{abstract}; STDOUT->binmode(':encoding(UTF-8)'); STDOUT->print($template->render_string(<<'HTML', {abstract => $abstract})); <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <p><: $abstract :></p> </body> </html> HTML __END__ … <body> <p><jats:p> ‘Jihadism’ (also kno…