use strict; use warnings; my $sId=''; my $sAttribute=''; my $sValue=''; while (my $sLine = ) { chomp $sLine; #figure out the id of the current record if ($sLine !~ /^\s*$/) { # $sId is '' when we read the first line if (!$sId) { # first line of record contains id, e.g. vfiler0, vfiler1, etc # id is first run of non-white characters - store it in $sId ($sId) = ($sLine =~ /^\s*(\S*)/); } #skip all vfiler0 record lines next if ($sId eq "vfiler0"); #get IP addreses for other records if attribute is "IP Address" #attribute name goes from first non-white character to first ':' ($sAttribute, $sValue) = ($sLine =~ /^\s*(\S[^:]*):\s*(\S*)/); if ($sAttribute && ($sAttribute eq 'IP address') && $sValue) { print "$sValue\n"; } } elsif ($sLine =~ /^\s*$/) { # records divided by entirely blank lines # when not in record set id to '' $sId=''; } #print STDERR "line ($sId): <$sLine>\n"; }