NAME PYX::Utils - A perl module for PYX common utilities. SYNOPSIS use PYX::Utils; my $decoded_text = decode($text); my $encoded_text = encode($text); my $decoded_text = entity_decode($text); my $encoded_text = entity_encode($text); SUBROUTINES "decode($text)" Decode characters. Currently decode newline to '\n'. Returns decoded text. "encode($text)" Encode characters. Currently encode '\n' to newline. Returns encoded text. "entity_decode($text)" Decode entities. - '<' => '<' - '&' => '&' - '"' => '"' Returns decoded text. "entity_encode($text)" Encode some chars for HTML/XML/SGML. Currenctly encode these characters: - '<' => '<' - '&' => '&' - '"' => '"' Returns encoded text. EXAMPLE1 use strict; use warnings; use PYX::Utils qw(decode); # Text. my $text = "foo\nbar"; # Decode. my $decoded_text = decode($text); # Print to output. print "Text: $text\n"; print "Decoded text: $decoded_text\n"; # Output: # Text: foo # bar # Decoded text: foo\nbar EXAMPLE2 use strict; use warnings; use PYX::Utils qw(encode); # Text. my $text = 'foo\nbar'; # Encode text. my $encoded_text = encode($text); # Print to output. print "Text: $text\n"; print "Encoded text: $encoded_text\n"; # Output: # Text: foo\nbar # Encoded text: foo # bar EXAMPLE3 use strict; use warnings; use PYX::Utils qw(entity_decode); # Text. my $text = 'foo<&"bar'; # Decode entities. my $decoded_text = entity_decode($text); # Print to output. print "Text: $text\n"; print "Decoded entities: $decoded_text\n"; # Output: # Text: foo<&"bar # Decoded entities: foo<&"bar EXAMPLE4 use strict; use warnings; use PYX::Utils qw(entity_encode); # Text. my $text = 'foo<&"bar'; # Encode entities. my $encoded_text = entity_encode($text); # Print to output. print "Text: $text\n"; print "Encoded text: $encoded_text\n"; # Output: # Text: foo<&"bar # Encoded text: foo<&"bar DEPENDENCIES Exporter, HTML::Entities, Readonly. SEE ALSO Task::PYX Install the PYX modules. REPOSITORY AUTHOR Michal Josef Špaček skim@cpan.org LICENSE AND COPYRIGHT © 2005-2020 Michal Josef Špaček BSD 2-Clause License VERSION 0.06