open(F,"foo"); foreach(){ if ($_ =~ /^iff/){ print "A line starts with iff\n"; }elsif($_ =~ /^if/){ print "A line starts with if\n"; } } close F;