sprintfとhex

まずsprintfがprintと同じものかと誤解していた。
そうじゃなくてフォーマットした文字列を返してくれるのね。
16進数⇔10進数変換はこんな感じ。

print hex '1f', "\n";
print sprintf "%x", 31, "n";