SPEC: Read 1376 byte binary file into uint16_t array overwrite item[16] with dec<7360> = 0X1cc0 overwrite item[22] with dec<4912> = 0X1330 Write file to disk sub prefix_hdr() { $hsize=1376; # Size of 16-bit grayscale tif header $hfn='d:/pic/misc/gray.3689x2462.hdr'; # Md5 ~29992 $brfn='6s-254550.7360x4912.blue.raw'; # photoshops $rsize=-s $brfn; $mutant='blue.7360x4912.tif'; open(H, "<$hfn"); binmode H; $bread=read(H, $hdr, $hsize); close H; printf("Read $bread B from $hfn\n"); @rgb=unpack("S*", $hdr); # RAW RGB UShort array printf("RGB[16]=%hu, [22]=%hu\n", $rgb[16], $rgb[22]); $rgb[16]=pack("S", 7360); # Overwrite 3689 with 7360 $rgb[22]=pack("S", 4912); # 2462 -> 4912 printf("FIXED? RGB[16]=0X%04hu, [22]=%hu\n", $rgb[16], $rgb[22]); } Read 1376 B from d:/pic/misc/gray.1376b.3689x2462.hdr RGB[16]=3689, [22]=2462 << PERFECT! Argument "└^\" isn't numeric in printf Argument "0^S" isn't numeric in printf FIXED? RGB[16]=0X0000, [22]=0 <<<<<