Paul Tremblay <[EMAIL PROTECTED]> wrote:
> Is there a way to convert a decimal number to a hexidecimal
> number in perl?
$ perldoc -f sprintf
> I have expressions like this:
>
> \u8195\'20
> \u9824\'3f
>
> The number after the u is a decimal number that needs to be
> converted to hexidecail. The number after the second slash
> needs to simply be elimianted. Thus, the two lines above
> should look like:
>
>  
> ♠
my $dec = qr|\\u(\d{4})|;
my $hex = qr|\\'[[:xdigit:]]{2}|;
s/$dec/sprintf "&#x%x;", $1/eg;
s/$hex//g;
Or if this is what you mean:
s/$dec $hex/sprintf "&#x%x;", $1/xeg;
HTH
--
Steve
perldoc -qa.j | perl -lpe '($_)=m("(.*)")'
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]