# consider some changes to make your life easier
# process the input and be done with it...
die"error $!\n" unless open hanr,"splitin.pl";
my @lines = <hanr>;
close hanr;
my $r = ''; # its easier to debug when you have a scalar you can print
+ later, rather than printing line by line...
for my $line ( @lines ) {
# odd since $outcome is undef .. ?
next unless $line =~ /^\$outcome /x;
$line =~ s/.{9,9}(.+)../$1/; # get the middle chars
$r .= $line; #append
# print hanw "$mess , \n" # why chomp then add \n back in? Just l
+eave it there....;
}
# process the output here
die $! unless open hanw, ">output.csv";
print hanw $r;
close hanw;