in reply to Re: 5.42: Does m// toss a string around?
in thread 5.42: Does m// toss a string around?
Ah, thanks. If I understand correctly, it was 5.42 which fixed the long-standing issue with "pack 'P',".
(I think the PV method constructs new string rather than returns numeric value. I'll use "pack 'P'," for the next example, for brevity of output over Devel::Peek::Dump; there's no 5.42 below)
Wild goose chase, then, being sidetracked with imagined issue with 5.42, but initially I investigated s///, not m//. I now suspect similar reasons, related to COW, can you explain please? The 5.18 re-uses string buffer when new length is either the same or less than original. The 5.20 and then 5.26 loose both abilities.
print "$^V\n"; my $x = '0123456789'; { my $s = "$x$x"; $s =~ s/(.)$/a/; printf "%x\n", unpack "Q", pack "P", $s; $s =~ s/(.)$/b/; printf "%x\n", unpack "Q", pack "P", $s; } { my $s = "$x$x"; $s =~ s/.$//; printf "%x\n", unpack "Q", pack "P", $s; $s =~ s/.$//; printf "%x\n", unpack "Q", pack "P", $s; } __END__ v5.18.4 29cdda8 29cdda8 29ce1e8 29ce1e8 v5.20.3 2b774f8 2b774f8 2b76b78 2b76f38 v5.26.3 2c9e118 2c9d7b8 2c9da88 2b4ae88
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: 5.42: Does m// toss a string around?
by ikegami (Patriarch) on Jan 22, 2026 at 13:50 UTC | |
by Anonymous Monk on Jan 29, 2026 at 23:30 UTC | |
by ikegami (Patriarch) on Jan 30, 2026 at 18:59 UTC | |
by Anonymous Monk on Jan 30, 2026 at 22:37 UTC | |
by Anonymous Monk on Jan 30, 2026 at 22:47 UTC |