Michael Kavanagh wrote:
> 
> I thought it would be good to be able to do this:
> 
> $item = "<blah>";
> $item  =~ tr/<>/(&lt;)(&gt;)/;

tr/// will translate the '<' to a '(' and the '>' to a '&'.

> 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?


$item =~ s{([<>])} {$1 eq '<' ? '&lt;' : '&gt;'}ge;


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to