http://www.perlmonks.org?node_id=824878


in reply to Re: Multiple line records from a command string
in thread Multiple line records from a command string

You could also break this up a bit and handle the input per record the way you would like. Personally I also find this a little easier to read and maintain. The key from above is setting the input line separator:

$/ = "\nS"; # or $/ = "Symmetrix ID:\n"

Which will allow you to open the command output to a filehandle and use a while loop, where each iteration is an individual record. You can then easily parse out the information you want:

open(FH,"-|", "symdev list -v") or die $!; while (<FH>) { my $symm_id = my $others = undef; # or ''; if ( m/Symmetrix ID/ ) { $symm_id = ( m/Symmetrix ID\s+:\s+(\d+)/ ); } # etc }

HTH!