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

In reply to Re^2: 5.42: Does m// toss a string around? by Anonymous Monk
in thread 5.42: Does m// toss a string around? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.