in reply to Re: Text::ExtractWords exhibits incomprehensible behavior?
in thread Text::ExtractWords exhibits incomprehensible behavior?

Yes, exact same way, despite being at different addresses:
#!/usr/bin/env perl use v5.38; use Text::ExtractWords qw(words_list); say $^V; my $text = "12/21/84 Bob's 21st b'day was a wine-and-dine."; my $copy = $text; say "Text: $text"; say "Copy: $copy"; printf("%s %s\n", \$text, \$copy); my @list; words_list(\@list, $copy, {minwordlen => 2, maxwordlen => 26 }); say "Found words: " . join ' ', map {"[$_]"} @list; say "Text: $text"; say "Copy: $copy"; printf("%s %s\n", \$text, \$copy); __END__ v5.40.0 Text: 12/21/84 Bob's 21st b'day was a wine-and-dine. Copy: 12/21/84 Bob's 21st b'day was a wine-and-dine. SCALAR(0x140829a68) SCALAR(0x1408299d8) Found words: [12] [21] [84] [bob's] [21st] [b'day] [was] [a] [wine-and +-dine] Text: 122184bob's21stb'daywasawine-and-dine Copy: 122184bob's21stb'daywasawine-and-dine SCALAR(0x140829a68) SCALAR(0x1408299d8)

Replies are listed 'Best First'.
Re^3: Text::ExtractWords exhibits incomprehensible behavior?
by etj (Priest) on Jun 16, 2024 at 21:54 UTC
    That's the SV addresses that are different. Try Devel::Peek's Dump function to see what the PV is? I suspect this is supposed to be copy-on-write (COW), but that the XS code is just overwriting the (still-shared) data area without doing the correct COW API stuff.
      That must be it.
      v5.40.0 Text: 12/21/84 Bob's 21st b'day was a wine-and-dine. Copy: 12/21/84 Bob's 21st b'day was a wine-and-dine. SV = PV(0x15780b090) at 0x1578242d0 REFCNT = 1 FLAGS = (POK,IsCOW,pPOK) PV = 0x6000019a1fe0 "12/21/84 Bob's 21st b'day was a wine-and-dine." +\0 CUR = 46 LEN = 48 COW_REFCNT = 2 SV = PV(0x15780b0b0) at 0x157824258 REFCNT = 1 FLAGS = (POK,IsCOW,pPOK) PV = 0x6000019a1fe0 "12/21/84 Bob's 21st b'day was a wine-and-dine." +\0 CUR = 46 LEN = 48 COW_REFCNT = 2 Found words: [12] [21] [84] [bob's] [21st] [b'day] [was] [a] [wine-and +-dine] Text: 122184bob's21stb'daywasawine-and-dine Copy: 122184bob's21stb'daywasawine-and-dine SV = PV(0x15780b090) at 0x1578242d0 REFCNT = 1 FLAGS = (POK,IsCOW,pPOK) PV = 0x6000019a1fe0 "12\x0021\x0084\x00bob's\x0021st\x00b'day\x00was +\x00a\x00wine-and-dine\x00"\0 CUR = 46 LEN = 48 COW_REFCNT = 2 SV = PV(0x15780b0b0) at 0x157824258 REFCNT = 1 FLAGS = (POK,IsCOW,pPOK) PV = 0x6000019a1fe0 "12\x0021\x0084\x00bob's\x0021st\x00b'day\x00was +\x00a\x00wine-and-dine\x00"\0 CUR = 46 LEN = 48 COW_REFCNT = 2
        I'd suggest filing a bug with the module with your nice short testcase, since it's clearly not supposed to do that.