Why use negative-width assertions, when you're already using the /m flag?
To catch the broken lines. Yours is a very elegant construction, which I intend to steal, but I don't think that snippet meets the original requirements as it is. if you knew the tags wouldn't contain numerals, which I doubt, you could change it to:
my $info = do { local $/; <DATA> }; my %lines = $info =~ /(\d+): ([^\d]+)/gs;
but otherwise I can't see an alternative to the (?:^|\n).
btw, is there any way to catch the matched values during a split? it would make this nice and tidy.
update: damnation. redundant again.
another update: I couldn't resist shrinking gjb's cheaper version and introducing a useful but quite unrequested array reference:
my ($key, %data); for (<DATA>) { /^(?:(\d+):\s*)*(.+)$/; push @{ $data{ $key = $1 || $key } }, $2; }
In reply to Re: Re: Matching over multiple lines in a scalar
by thpfft
in thread Matching over multiple lines in a scalar
by Rich36
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |