use warnings; @ARGV = 'Google_1'; my @results; while ( ){ chomp $_; if($_ =~m/head/){ push (@results, $_); } } print "@results\n";