in reply to Re: map to hash of arrays
in thread map to hash of arrays

Not exactly. Let me try my explanation again. Here is a chunk of sample data to illustrate what I'd like to do.
Row 17 object_label : yang object_id : 123456 Row 18 object_label : yang object_id : 789101112 Row 19 object_label : yang object_id : 13141516171819
The data comes in exactly like that, line by line. I need to ignore the Row \d+ lines and grab the rest of the information, so that I end up with a hash of arrays where 'object_label' are used as keys and 'object_id' with the same 'object_label' are items in an array.
%hash = { 'yang' => [ '123456', '789101112', '13141516171819' ] }

Replies are listed 'Best First'.
Re^3: map to hash of arrays
by ccn (Vicar) on Jul 26, 2004 at 14:26 UTC

    please try this: push @{$hash{$1}}, $2 while $data =~ /object_label\s+:\s+(\S+)[^:]+:\s+(\S+)/g;

      That worked perfectly, thanks. So is the regex treating the data read in as a single string? There are line breaks, which I thought would require the /m modifier to get away with something like this. I understand the [^:]+ part that continues matching on anything that is not a :, but I thought the regex would end at the first line break?