in reply to Re^4: Adding data to hashes & comparing
in thread Adding data to hashes & comparing

You may have figured this out by now, but perhaps you could post some data. I'm not exactly sure what you are trying to do with if ($key =~ '%h'). %h isn't a regular expression. Did you mean if ($key eq '%h') or did you mean if ($key =~ /%h/) ? You might want to review perlop for operators and perlretut for regular expressions.

Also don't forget that you can use if (...) {...} elsif (...) {...} for mutually exclusive conditions. Your code as written would compare against the 2nd and 3rd if once it was done with a successful match on '%h'. See perlsyn for more information.

Finally, I think you might find debugging this a bit easier if you use strictures. Often when data doesn't end up where you expect it, its because of undefined variables floating around. Using strictures can help detect problems like that. Put the following just under the shabang line at the top of your file:

use strict; use warnings;

Best, beth