As you can see from the Perl code snippets below, I am putting the $document string (which contains text from a text document) into an @document array. Then printing out $document before stemming it. I am then stemming the @document array and then the stemmed results get put into my $stemmed_words_anon_array string but I get: ARRAY(0xc99b3c) which is like a memory address.
What am I doing wrong? My results_stemmed.txt also contains the ARRAY(0xc99b3c) inside it.
# Put string of main document into an array
my @document = split(' ', $document);
# Print the $document string to check it before stemming it
print $document;
open (FILE_STEM, '>results_stemmed.txt');
use Lingua::Stem qw(stem);
my $stemmed_words_anon_array = stem(@document);
# $stemmed_words_anon_array is just receiving: ARRAY(0xcbacb) here
print FILE_STEM $stemmed_words_anon_array;
close(FILE_STEM);
print $stemmed_words_anon_array;
It’s a reference.
@$stemmed_words_anon_arraywill get you the array itself. For more on how to deal with references in Perl, seeperldoc perlref.