in reply to Re: Removing HTML tags from a string
in thread Removing HTML tags from a sting

wouldn't just a simple

foreach (@line){ $_ =~ s/\</\&lt\;/g; $_ =~ s/\>/\&gt\;/g; }

work just as well?

John J Reiser
newrisedesigns.com

Replies are listed 'Best First'.
Re(3): Removing HTML tags from a string
by chip (Curate) on May 21, 2002 at 01:38 UTC
    Well, if that's what I meant, I probably would have typed something like this:

    for (@line) { s/</&lt;/g; s/>/&gt;/g; }

    But to answer your question: It's actually less brain drain to use a tested and complete module than to write equivalent code -- especially when the code isn't equivalent at all.... Or were you under the impression that the only dangerous characters for HTML rendering are "<" and ">"?

        -- Chip Salzenberg, Free-Floating Agent of Chaos