_data.txt_ abc:AB CD:100 def:DE FG:101 ghi:GH IJ:102 abc:AB CD:100 ghi:GH IJ:103 #### my $file='source_data\data.txt'; open FILE, $file or die "FILE $file NOT FOUND - $!\n"; while (){ chop $_; my ($a, $b, $c) = split /:/, $_; my $r = [$a, $b, $c]; my @arr = $r->[0]; my @matches = grep $_ eq "abc", $arr[0]; foreach my $i (@matches) { print $_."\n"; } } #### _ouput_ abc:AB CD:100 abc:AB CD:100