splitting into paras

Simon Wistow simon at thegestalt.org
Wed Jan 11 09:21:59 GMT 2006

Clearly the Beer Gremlins have made my brain fuzzy but, what the hell,
it's a rainy Wednesday and the part of my brain that's been doing C++
for the last two weeks is screaming "Don't be a fool! Stop trying to use 
me! I'm broken and misty from beer!" so hence I mail you, this esteemed 

Given this

-- >8 --

# no idea where the input is coming from so need to be liberal
my $crlf = qr/\x0a\x0d|\x0d\x0a|\x0a|\x0d/;

my $text = <<EOP;
10 < p > 100

gin & tonic

arbitary third paragraph
with multiple lines
that I thought of whilst
watching the film Signs

my @paras = split /$crlf{2,}/, $text;

-- >8 --

I'd expect @paras to be 3 elements long. 

Can I get this to work? Can I blox. 

Various voodoo sprinklings of ?: and brackets have not helped.  

split/$crlf/ splits all the lines up fine. 

Clearly my regex skills have severely failed me and thus I require help
and explanation for this poor baffled bear.


More information about the london.pm mailing list