On May 10, Paul Cotter said:

>What combination of sprintf/pack/upack/asc/hex/xyz.pm etc will allow me
>to convert a string in to a string hex equivalent. I dare say, in Perl's
>little quirks there is an arcane subroutine called something like dtcnvx
>that does just what I want...

Sadly, the oct() and hex() functions are poorly named; they should be
from_oct() and from_hex().  You want to use sprintf().

  $as_hex = sprintf "%x", $num;
  $as_hex = sprintf "%#x", $num;  # adds a leading "0x"

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734

Reply via email to