in reply to Why multiline regex doesn't work?

I really don't understand what you are trying to match ... perhaps you simplified your example too much? At any rate, why not use split?

use strict; use warnings; use Data::Dumper; my $s = <<'ENDSTR'; aaa : AAA bbb : BBB ccc : CCC ENDSTR my %hash = map { split( /\s+:\s+/, $_, 2) } split ( /\n/, $s ); print Dumper \%hash; __END__ $VAR1 = { 'bbb' => 'BBB', 'ccc' => 'CCC', 'aaa' => 'AAA' };

UPDATE:
But simple splitting DOES work here.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: Why multiline regex doesn't work?
by nbd (Novice) on Jun 08, 2015 at 23:57 UTC
    I try to learn how to use ^ and $ anchors within a string for cases where simple splitting doesn't work. And cannot see what's wrong with this simple example.