in reply to Getting only part of a text file...

The scalar context range operator (flip flop) can be powerful fu:

use strict; use warnings; my $match = 'lvol[35]'; while (<DATA>) { next if ! (my $it = /^LV Name/ .. /^LV Name/ && ! /$match/); if ($it =~ /E0/) { print "---\n"; next; } print "$it: $_"; } __DATA__ --- Logical volumes --- LV Name /dev/vg00/lvol3 VG Name /dev/vg00 Various stuff omitted LV Name /dev/vg00/lvol4 VG Name /dev/vg00 Various stuff omitted LV Name /dev/vg00/lvol5 VG Name /dev/vg00 Various stuff omitted LV Name /dev/vg00/lvol6 VG Name /dev/vg00 Various stuff omitted

Prints:

1: LV Name /dev/vg00/lvol3 2: VG Name /dev/vg00 3: Various stuff omitted --- 1: LV Name /dev/vg00/lvol5 2: VG Name /dev/vg00 3: Various stuff omitted ---

If you are unfamiliar with it take a look at Flipin good, or a total flop?.


DWIM is Perl's answer to Gödel