use strict; use warnings; while (){ # Returns true after matching "LV Name", # and returns false after # matching "--- Logical extents ---". if (/^LV Name/ .. /--- Logical extents ---/){ print "$_"; } } __DATA__ Line above --- Logical volumes --- LV Name /dev/vg00/lvol3 VG Name /dev/vg00 LV Permission read/write ... --- Logical extents --- Line below