in reply to Re: Pattern match for split() - need match but not match syntax
in thread Pattern match for split() - need match but not match syntax

While there's nothing wrong with your $LINE_PATTERN regex I think it would be simpler to keep the record and field/value processing separate. To my eye it looks tidier and easier to maintain but others may disagree.

use strict; use warnings; use Data::Dumper; my $app_text = qq{one:partridge\ntwo:\nturtle doves\nthree:french hens\n}; my %fvPairs = map { split m{:\n?} } map { split m{(?<!:)\n} } $app_text; print Data::Dumper->Dumpxs( [ \ %fvPairs], [ q{*fvPairs} ] );

produces ...

%fvPairs = ( 'three' => 'french hens', 'one' => 'partridge', 'two' => 'turtle doves' );

Cheers,

JohnGG