in reply to regex problem

It can be with a simple if/elsif and a simple regex, but i suggest you test what the others said. Take a deep breath and dive into the regex sea.
open(F,"foo"); foreach(<F>){ if ($_ =~ /^iff/){ print "A line starts with iff\n"; }elsif($_ =~ /^if/){ print "A line starts with if\n"; } } close F;


``The wise man doesn't give the right answers, he poses the right questions.'' TIMTOWTDI

Replies are listed 'Best First'.
Re^2: regex problem
by monarch (Priest) on Jun 08, 2005 at 12:55 UTC
    The important thing with this approach is the order of the tests. Searching for the longest match first is the only way to be successful here, a bit like looking for a routing table match using binary arithmetic (the longest prefix match wins).