in reply to Safer (and cleaner) way to print user-supplied text.

Here's an approach without using another module:
my $bad  = { 
            '&' => '&',
            '|' => '&pipe;', # I don't know this one :-)
            ';' => ';', # This one either
           };
my $find =  join '', keys %{$bad};
$string  =~ s/([$find])/$bad->{$1}/g;
Enjoy
--
Casey
  • Comment on Re: Safer (and cleaner) way to print user-supplied text.