in reply to Re: splitting files by number of words
in thread splitting files by number of words

Erm . . .

@total_words = split while (<DATA>);

only works because you've got a single line of test data. With more than one line you'd wind up only getting the number of words in the last line processed. The correct way to do what you're attempting would be along the lines of push @total_words, split; however you'd then wind up keeping all of the words in memory which, given the original constraint of "very large files", is probably not going to be viable.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^3: splitting files by number of words
by si_lence (Deacon) on Aug 06, 2009 at 13:26 UTC
    or you could just use
    $total_words += split while(<DATA>);
    cheers, si_lence
Re^3: splitting files by number of words
by bichonfrise74 (Vicar) on Aug 06, 2009 at 16:58 UTC
    Thanks, I didn't notice that.