$stemmed_words is a reference to an array. Dereference it before using it, eg $$stemmed_words[0] or $stemmed_words->[0]: that index in the brackets works just like an array that isn't being dereferenced ($foo[0]), it's just the sigil or dereferencing arrow that's the difference. See perlreftut and maybe perldocdsc.