in reply to Re^2: putting text into array word by word
in thread putting text into array word by word

check your file from which you are taking the input.
since you used +> parameter earlier , perl have deleted its contents.
  • Comment on Re^3: putting text into array word by word

Replies are listed 'Best First'.
Re^4: putting text into array word by word
by jms53 (Monk) on Jan 09, 2012 at 18:55 UTC

    PERFECT, Thank you sooo much

    I can now go back to calmly pseudo-geeking.

      OK, now that's solved, let's look at the definition of 'word' (yes, things are going to get hairy...). Take this sentence, for example:

      "No, he said."

      The 'words' that your current code would extract are:

      "No, he said."

      Is that really what you want? Or would you prefer:

      No # or, better, 'no' he said

      ?

        during the foreach loop I remove punctuation and set to lowercase (such that No and no are the same word.
        while (<FILE>) { my @these_words = split(' ', $_); foreach my $this_word (@these_words) { $this_word =~ s/[[:punct:]]//g; $this_word = lc($this_word); push @all_words, $this_word; } }