in reply to Shorten a list...

One way is to keep track of the group count in a hash:
use warnings; use strict; my %groups; while (<DATA>) { next unless /\S/; chomp; $groups{$_}++; } for (sort keys %groups) { print "$_\n" if $groups{$_} > 1; } __DATA__ Group 1 Group 2 Group 3 Group 3 Group 4 Group 5 Group 5 Group 5
Prints...
Group 3 Group 5

Replies are listed 'Best First'.
Re^2: Shorten a list...
by la (Novice) on Oct 16, 2011 at 00:18 UTC

    Thanks for the quick reply. I want the resultant list to read:

    Group 3
    Group 3
    Group 5
    Group 5
    Group 5

    is this possible with the code you have given?

      You're welcome.

      The code I provided can be modified to produce that output. Give it a try.