use strict; use warnings; my $stats; open my $DEVICE_IN, "<", 'stat.dat' or die "Cannot open input device: $!"; $stats = <$DEVICE_IN>; close $DEVICE_IN; $stats = pack( 'b16', reverse( unpack( 'B16', $stats ) ) ); vec($stats, 2, 1) = 0; # Reset bit 2 vec($stats, 6, 1) = 1; # Set bit 6 vec($stats, 10, 1) ^= 1; # Toggle bit 10 $stats = pack( 'b16', reverse( unpack( 'B16', $stats ) ) ); open my $DEVICE_OUT, ">", 'newstat.dat' or die "Cannot open output device: $!"; print $DEVICE_OUT $stats; close $DEVICE_OUT; #### C:\Users\Bill\forums\monks>xxd stat.dat 00000000: f531 .1 C:\Users\Bill\forums\monks>xxd newstat.dat 00000000: d711 .. C:\Users\Bill\forums\monks>