#!/usr/bin/perl -l
# http://perlmonks.org/?node_id=1185742
use strict;
use warnings;
$/ = 'Dumpdata example
-----------------
';
while(<DATA>)
{
chomp;
my @answer = map s/\s+/ /gr =~ s/\s+\z//r =~ s/.*/"$&"/sr,
/^Warning (.*)/gm,
/^\s*\w+:\s*(\S.*(?:\n(?!\s*\w+:)\s*\S.*)*)/gm;
@answer and print join '; ', @answer;
}
__DATA__
Dumpdata example
-----------------
Warning bad news here
Detail: Some really nice infos these are
Info: This is a problem
but there is a solution
Spec: 2nd of 4
Dumpdata example
-----------------
Warning test
Detail: foo
bar
Info: quz
baz
Spec: blah