in reply to Comparing packed variables
Yes:
use strict; use warnings; for my $pair([253, 254], [253, 257]) { my $result = pack("S<", $pair->[0]) cmp pack("S<", $pair->[1]); print "Little: $pair->[0] cmp $pair->[1] = $result\n"; $result = pack("S>", $pair->[0]) cmp pack("S>", $pair->[1]); print "Big: $pair->[0] cmp $pair->[1] = $result\n"; $result = pack("S", $pair->[0]) cmp pack("S", $pair->[1]); print "Native: $pair->[0] cmp $pair->[1] = $result\n"; }
Prints:
Little: 253 cmp 254 = -1 Big: 253 cmp 254 = -1 Native: 253 cmp 254 = -1 Little: 253 cmp 257 = 1 Big: 253 cmp 257 = -1 Native: 253 cmp 257 = 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing packed variables
by Jaap (Curate) on Mar 18, 2021 at 10:33 UTC | |
by GrandFather (Saint) on Mar 18, 2021 at 10:38 UTC |