Writing the New Report
 
 
open COST, "<cost.txt" or die "open cost.txt: $!";
    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
  Notes: 
  
  
Here we read each line from the costs text file,
skip lines that don't start with digits,
extract the product and cost,
apply the margin (or a default),
apply the note (or a default),
Again: very few lines of code and just about every line directly related to the task.