in reply to Deleting a word in a file!

There are very few situations where you would want to treat hash keys the same as hash values, which is what you are doing when you grep { ... } %hash, or foreach ( %hash ) { ... }. That's probably bug as a consequence of not understanding how to use Perl's hashes. It often does make sense to iterate over a hash's keys (generate a list of them using keys), or a hash's values (values). Likewise, my( %hash ) = <INFILE> is almost certainly a bug too, unless your input file looks like this:

some key some value some key some value

...which is unlikely in general, and definitely not the case for your data sets.

I'm going to assume that you're required, for some reason, to use newline delimited flat files for your inventory list, and your storage list. Though it's probably not the most time-efficient approach, I would probably just use Tie::File, and be done with it.


Dave