1

In PHP it's as simple as htmlspecialchars, how to do it in Perl?

Je Rog
  • 5,387
  • 8
  • 37
  • 47
  • If you are generating HTML using one of the templating modules (e.g.: Template Toolkit, HTML::Mason etc) then the template system will provide a way to escape the output as required. – Grant McLean Aug 02 '11 at 21:49

1 Answers1

6

Use the HTML::Entities module.

daxim
  • 38,703
  • 4
  • 63
  • 128
spraff
  • 30,806
  • 22
  • 110
  • 214
  • 2
    Or the `html` filter in Template-Toolkit (hint: Using a template module is a good idea if you are generating HTML). – Quentin Aug 01 '11 at 15:43
  • Nope,it's different according to this answer, the answer prefers `htmlspecialchars` to `htmlentities`: http://stackoverflow.com/questions/46483/htmlentities-vs-htmlspecialchars/46491#46491 – Je Rog Aug 01 '11 at 15:56
  • 2
    @Je Rog `HTML::Entities` is equivalent to both of those PHP functions, but its default behavior is like `htmlspecialchars`. – hobbs Aug 01 '11 at 16:45