use strict; my $countline = 0; my $mytest; open (MYFILE,") { my @datas= split (/\s+/, $mytest); if ($datas[0] eq "Hello") { $countline++; } my @test1 = $countline; print $test1[0]; }