use strict; use warnings; open(MYFILE, '<', 'testing.txt') || die "Could not open input file\n"; my @array = grep { my @datas = split(/\s+/, $_); $datas[0] eq "Hello" } ; # my $countline = @array; print("The matching lines:\n"); foreach my $line (@array) { print($line); }