use strict; while (<>) { if (/^>lmo0025/ .. /^>lmo0027/) { last if /^>lmo0027/; print; } }