On Thu, 2002-01-31 at 09:06, KAVANAGH, Michael wrote: > 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? > > Thanks > Mike > >
I could be wrong, but I thought tr/// and y/// were only for characters. I think you might want: my %entity = ( '<' => '<', '>' => '>', '&' => '&', ); my $item = "<blah>"; $item =~ s/([<>&])/$entity{$1}/ge; -- Today is Sweetmorn the 31st day of Chaos in the YOLD 3168 Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]