#!/usr/bin/perl
use warnings;
use strict;
open my $IN, '<', 'input.txt' or die "Cannot open 'input.txt' becaus
+e: $!";
open my $OUT, '>', 'output.txt' or die "Cannot open 'output.txt' becau
+se: $!";
# Input record separator
$/ = '+';
while ( <$IN> ) {
# skip empty records
next unless /\S/;
# remove input record separator
chomp;
my ( $id, $name ) = ( $1, $2 ) if s/ \s* \^ \s* ( \d+ ) \s* % \s*
+( .+? ) \s* \.\| \s* //x;
for my $data ( split /\s*;\s*/ ) {
print $OUT join( ',', map qq/"$_"/, $id, $name, split /\s*-\s*
+/, $data ), "\n";
}
}