2 Replies - 4125 Views - Last Post: 20 July 2012 - 07:53 AM

#1 DemiSheep  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 24-August 10

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.

# 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;



Is This A Good Question/Topic? 0
  • +

Replies To: perl code causing my string to receive ARRAY(0xc99b3c)

#2 sepp2k  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2089
  • View blog
  • Posts: 3,181
  • Joined: 21-June 11

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.
Was This Post Helpful? 2
  • +
  • -

#3 DemiSheep  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 24-August 10

Re: perl code causing my string to receive ARRAY(0xc99b3c)

Posted 20 July 2012 - 07:53 AM

Thanks that helped a lot!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1