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

html entity conversion... one liner?

Thread Next
From:
KAVANAGH, Michael
Date:
January 31, 2002 06:07
Subject:
html entity conversion... one liner?
Message ID:
852ED745A1B8D411BBD900B0D0789E0C03D73AD7@EXC05.oup.co.uk
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?

Thanks
Mike



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About