in reply to Perl Regular Expressions
Update: Sorry, accidentally submitted too early. Anyway, to handle the continuation lines, we need a loop:my ($key, $value) = split /\s*-\s+/, $line;
while (<>) { if (/^(\S+)\s*-\s+(.+)$/) { push @pair, [$key,$value] if $key; # save prev pair $key = $1; $value = $2; } elsif (/^\s+-\s+(.+)$/) { $value .= $1; } else { print "Badly formatted line: $_\n"; } }
-Mark
|
|---|