for(@Input) { if(/$Start/) { $State = 1; } elsif(/$Finish/) { $State = 0; } else { $State = $State; } ($State) ? do_this() : do_that; }