use strict; use warnings; my %fragments; while ( my $line = ) { chomp $line; my ( $term, $rest ) = split ' ', $line, 2; push @{ $fragments{$term} }, $rest; } for my $term ( keys %fragments ) { print "There are $term " . ( join ' and ', @{ $fragments{$term} } ) . ".\n"; } __DATA__ big businesses fast red cars big movie companies fast light planes fast animals big bad wolves