# 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) or something similar...why?
print FILE_STEM $stemmed_words_anon_array;
close(FILE_STEM);
print $stemmed_words_anon_array;
2 Replies - 3259 Views - Last Post: 20 July 2012 - 07:53 AM
#1
perl code causing my string to receive ARRAY(0xc99b3c)
Posted 19 July 2012 - 08:24 AM
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 them 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.
Replies To: perl code causing my string to receive ARRAY(0xc99b3c)
#2
Re: perl code causing my string to receive ARRAY(0xc99b3c)
Posted 19 July 2012 - 08:18 PM
ARRAY(0xc99b3c) is a reference to an (anonymous) array. To access it, you need to dereference it. For example you print it by writing print @$stemmed_words_anon_array;. For more information see the perldoc on references.
#3
Re: perl code causing my string to receive ARRAY(0xc99b3c)
Posted 20 July 2012 - 07:53 AM
Thanks that helped a lot!
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|