while() { next unless /^h/ .. /^h/; # stop processing the line unless we are between two lines starting with h somecode(); }