Rich36 has asked for the wisdom of the Perl Monks concerning the following question:

In a piece of code that I'm working on, I've got some report data that consists of a scalar that contains data about tags in a document and what line the tags are on. The data is organized so that there is a line number, followed by a colon, then the report data which can span multiple lines. What I'm trying to do is split the data up so that I've got a hash with the line numbers as the keys and the data as the values. The problem that I'm running into is when the data for a line number spans multiple lines ("\n" delimited). I'm attempting to use a while loop and regex to split the data up, but it's not exactly working right. Any help would be greatly appreciated...

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $info; $info .= $_ while(<DATA>); my %lines; while($info =~ m/(\d+)\: (.+?)/gms) { $lines{$1} = $2; } print Dumper (%lines); __DATA__ 3: Tag <test> found Tag <test> found 5: Tag <test> found 7: Tag <test> found 14: Tag <test> found 16: Tag <test> found 18: Tag <test> found 21: Tag <test> found 25: Tag <test> found 27: Tag <test> found 29: Tag <test> found 32: Tag <test> found 34: Tag <test> found 49: Tag <test> found 80: Tag <test> found 98: Tag <test> found Tag <test> found