in reply to Dividing a file into groups of two words and counting them

The main-loop should simply scan the file, split each line, and call a subroutine for each word.

Let's assume a global scalar $previous_word whose value is of-course initially undef. The subroutine checks this scalar to see if it is defined(). If so, it contains the first word and we've just been given the second, so tally it, then set $previous_word back to undef. Otherwise, store the word in $previous_word and do nothing more.

Remember that you must account for the last word if the file contains an odd number. You can detect this case, after the loop ends, by checking to see if $previous_word is defined().