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

RE: html entity conversion... one liner?

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

Well. It is on one line ;)

John

-----Original Message-----
From: KAVANAGH, Michael [mailto:Kavanagm@oup.co.uk]
Sent: 31 January 2002 14:06
To: 'beginners@perl.org'
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?

Thanks
Mike



-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org


--------------------------Confidentiality--------------------------.
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


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