my %new_data = (); foreach ( @DATA ) { /^(.*?)\t.*$/; push @{$new_data{$1}}, $_; }