Writing the New Report
open COST, "<cost.txt" or die "open cost.txt: $!";
while ($line = <COST>) {
    next unless $line =~ m/^\d/;
    ($prod, $cost) = unpack 'A4 @20 A7', $line;
    $cost *= $prod_margin{$prod} || 1.10;
    $note  = $prod_notes{$prod}  || 'n/a';
    write;  # using format with $prod, $cost and $note
}
9