develooper Front page | perl.beginners | Postings from January 2002

RE: html entity conversion... one liner?

Thread Previous | Thread Next
John Edwards
January 31, 2002 06:12
RE: html entity conversion... one liner?
Message ID:
$item  =~ s/</&lt;/g; $item  =~ s/>/&gt;/g;

Well. It is on one line ;)


-----Original Message-----
From: KAVANAGH, Michael []
Sent: 31 January 2002 14:06
To: ''
Subject: html entity conversion... one liner?

I thought it would be good to be able to do this:

$item = "<blah>";
$item  =~ tr/<>/(&lt;)(&gt;)/;

to convert those <> symbols to their entity references.
however, the tr operator doesn't seem to like using () to group... any
comments on how to make this operation in to a one-liner?


To unsubscribe, e-mail:
For additional commands, e-mail:

This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About