in reply to left justify/pad hex value
A major reason for using computers is to avoid doing the same thing over and over again. If you find yourself repeating essentially the same line of code multiple times then most likely there is a better way to do it. For the example to hand you could:
use strict; use warnings; my @octets = (10, 34, 2, 252); printf "%02x\n", $_ for @octets;
Prints:
0a 22 02 fc
|
|---|