while ($i < 4) { $ID1=`printf "%024x", $i`; printf "Value of ID1 = $ID1\n"; $ID1 = join ' ', unpack("(A2)*",$ID1); print "After join command:$ID1\n"; $i++; } bash-3.00# ./genID.pl Value of ID1 = 000000000000000000000000, After join command:00 00 00 00 00 00 00 00 00 00 00 00 , Value of ID1 = 000000000000000000000001, After join command:00 00 00 00 00 00 00 00 00 00 00 01 , Value of ID1 = 000000000000000000000002, After join command:00 00 00 00 00 00 00 00 00 00 00 02 , Value of ID1 = 000000000000000000000003, After join command:00 00 00 00 00 00 00 00 00 00 00 03 ,