while ($line=<$fhin>) { ... next if $data[0]=~m/[\=\%]/; ... place where you print out ''; ... for my $word(@data){ ...