use strict; use warnings; my %data; while () { if (/Symmetrix ID:/) { # start of new record print_record(%data) if %data; %data = (); } elsif (/:/) { chomp; my ($k, $v) = split /\s*:\s*/; $k =~ s/^\s+//; $data{$k} = $v; } } print_record(%data) if %data; sub print_record { my (%data) = @_; my @params = ( 'Device Serial ID', 'Vendor ID', ); for (@params) { print "$_: $data{$_}\n"; } print "\n"; } __DATA__ #### Device Serial ID: 6000062081 Vendor ID: EMC Device Serial ID: 6000062082 Vendor ID: EMC2