use warnings; use strict; while () { if (/Name\s+LUN\s+(\d+)/){ my $lunid = $1; print "\n!$lunid!\n"; print $_; exit; } } __DATA__ Total Hard Errors: 0 Total Soft Errors: 0 Total Queue Length: 0 Name LUN 259 Minimum latency reads N/A