my $parameterFound = 0; # the flag while( my $line = <@data> ) # your code that claims to read the file line-by-line { if ($line =~ /Parameter/) { $parameterFound = 1 ;} # start reading real data now next if ($parameterFound == 0); # we are still in the header print .... }