in reply to Re^2: close end tag
in thread close end tag

What does this mean? You want to convert '<' to  &lt; and '>' to &gt;

Replies are listed 'Best First'.
Re^4: close end tag
by Anonymous Monk on Aug 27, 2009 at 08:51 UTC
    #!/usr/bin/perl while($line = <DATA>){ @valid_entities= ('<a>','<abbr>','<acronym>'); my %htmlenties = map { $_ =>1 } @valid_entities; $line =~ s/(<(\w+?)>)/exists $htmlenties{$1} ? $1 : defined ($2) ? "& +lt;$2&gt;" : "&lt;"/eg; print $line; } __DATA__ <helloe>How r u <a> www.google.com</a> <Hi>How r u </hi>
    Hi, I have replaced the '<' with &lt; and '>' with &gt;
    But now the problem is
    even if the tag has closing tag, the character get's replaced.
    Please tell me how to avoid it?