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"; } }