0000000: 0102 0304 0506 0708 090a 0b0c 0d0e 0f10 ................ #### use strict; use warnings; my $file = 'test.binary'; my $size = 16; #bytes to write to file; open ( my $fh, '>', $file ) or die "Unable to open $file - $!\n"; binmode $fh; my $byte = 0; for ( 1..$size ) { $byte++; $byte %= 256; my $char = pack 'C', $byte; # I tried both print and syswrite. I get the same results with each. syswrite( $fh, $char, 1); #print $fh $char; } close $fh; print "\nDONE\n"; #### 0000000: 0102 0304 0506 0708 090a 0b0c 0d0e 0f10 ................ 0000010: 0a .