open my $F, '+<', 'file.gz' or die $!; seek $F, -8, 2; my $c = getc($F); seek $F, -8, 2; print $F chr(ord($c) ^ 1);