in reply to Flipping the Sign Bit in pack()'ed Value
When I run the code with warnings, I'm getting
Argument "B" isn't numeric in numeric bitwise xor (^) at 1.pl line 10.
But even using
and changing the xor line touse feature qw( bitwise );
doesn't fix it according to your expectations:my $stoval = "$pckval" ^. 0x80;
$stoval = "B" ^. 0x80; # $stoval = [s28] - Expecting [194] $stohex = "0x" . (unpack 'H16', "s28"); # $stohex = [0x733238] - Ex +pecting [0xc2]
You need to use a character on the right hand side of the xor, too.
my $stoval = $pckval ^ "\x80"; # or my $stoval = $pckval ^ chr 0x80; # or my $stoval = $pckval ^ pack 'C', 0x80; # ...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Flipping the Sign Bit in pack()'ed Value
by marinersk (Priest) on Jun 09, 2025 at 13:30 UTC |