in reply to Counting Similar Strings

Yes, but that doesn't give the output which he wants, which is the total number of pairs. For each string, you can use the formula n(n-1)/2 to get the number of pairs (4 copies of a string = 4(3)/2, or 6 pairs), or just add all the pairs as you go:
use strict; use warnings; my (%hash, $pairs); while (<DATA>) { chomp; $pairs += $hash{$_}++; } print $pairs; __DATA__ string1 string2 string3 string1 string1 string7 string2