in reply to How to get hexadecimal output in specific format?

G'day mandalmanas5519,

Welcome to the monastery.

The documentation for sprintf has dozens of examples of how to compose the format and what the output looks like. So, for future reference, looking it up there would be a lot quicker than posting a question here and waiting for a reply.

Here's how to compose the format for the specific instance you have here.

  1. % — start format (yes, you know this already)
  2. %0 — padding with zeros
  3. %08 — 8 characters
  4. %08X — uppercase hex digits (you don't need uc)
$ perl -Mstrict -Mwarnings -E ' my $dec = 1211; say sprintf("%08x", $dec); say sprintf("%08X", $dec); ' 000004bb 000004BB

-- Ken