“Cache the data for other uses!”
dbmopen(%price_cache, "price_cache", 0644) or die …;
write; # using format with $prod, $cost and $note
$price_cache{$prod} = "$cost $note";
Notes:
The company grows and now stocks thousands of products.
To save time the derived price for each product can be saved in a simple DBM' database (support for which is built into perl) and made available to other perl programs.
Just two additional lines of code is all that's needed.
(A similar pair of lines is all that's needed to read the data.)