Script to encode HTML special characters

Have you grown tired of typing in all those HTML special characters? Use a perl script instead:

nano ~/bin/html_special_char_encoder.pl
#!/usr/bin/perl
use HTML::Entities;
while (<>) {
    print HTML::Entities::encode($_) ;
} ;
chmod +x ~/bin/html_special_char_encoder.pl

Just a quick test:

echo 'This is a test: "<&>"' | ~/bin/html_special_char_encoder.pl
This is a test: &quot;&lt;&amp;&gt;&quot;

HTML::Entities documentation

Leave a Reply

Your email address will not be published. Required fields are marked *