> -----Original Message----- > From: KAVANAGH, Michael [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 31, 2002 9:06 AM > To: '[EMAIL PROTECTED]' > Subject: html entity conversion... one liner? > > > I thought it would be good to be able to do this: > > $item = "<blah>"; > $item =~ tr/<>/(<)(>)/; > > 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?
In addition to all the suggestions you're getting, note that there is the HTML::Entities module on CPAN for encoding and decoding entities. It's part of the LWP distribution, I believe. use HTML::Entities; The one-liner is then: encode_entities($item); HTH -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]