ibm1620 has asked for the wisdom of the Perl Monks concerning the following question:
I'm looking for a module to extract words from a stream of text. I installed Text::ExtractWords and tried it:
#!/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."; say $text; my @list; words_list(\@list, $text, {minwordlen => 2, maxwordlen => 26 }); say "Found words: " . join ' ', map {"[$_]"} @list; say $text;
Note the output value of $text after call. How is it possible for any subroutine to modify a parameter, since I don't pass in a reference?v5.38.2 12/21/84 Bob's 21st b'day was a wine-and-dine. Found words: [12] [21] [84] [bob's] [21st] [b'day] [was] [a] [wine-and +-dine] 122184bob's21stb'daywasawine-and-dine
Moreover, I looked at Text::ExtractWords.pm and it's all basically boilerplate except maybe for one line, which I don't understand:
I feel like I'm missing something obvious here...bootstrap Text::ExtractWords $VERSION;
Update: I'm not able to step into words_list() using the debugger! It just proceeds to my next source line.
Update2: I even tried making a copy of $text (my $copy = $text) and passing $copy to words_list(), and afterwards *both* $copy and $text were munged. As Danny mentions below, this is XS code.
|
|---|