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