Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Why multiline regex doesn't work?

by jeffa (Bishop)
on Jun 08, 2015 at 23:31 UTC ( [id://1129557]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1129557]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-03-30 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found