@data = ; my @sorted_data = sort @data; foreach $line (@sorted_data) { chomp $line; $line =~ /(.*?)\,(.*?)\,(.*)/; $first = $1; $second = $2; $last = $3; if ($last eq $second) { if($second eq $first) { $print "$second really = $first\n"; } else { print "$last only = $first\n"; } } }