http://www.perlmonks.org?node_id=1018299


in reply to Processing words in a file.

I guess you need first word of each line from the file

use strict; use warnings; open FH, '<', "filename.txt" or die "Can not open file $!"; while(<FH>) { my ($first_word) = $_ =~ /^(\w+)/; if ($first_word eq 'your string') { #Your wish. } }