in reply to Can't get hash keys to print
Hello Daren, and welcome to the Monastery!
Glad to see that hippo’s answer was what you were looking for. In the future, you should give an example of the input file, together with the output you expect from that example, and the output you actually get.
But I want to point out that your strategy of performing a regular expression match on Return code is and then splitting on : is potentially fragile: if there is whitespace between the colon and the return code digit, this whitespace will be included in the hash key. So you could, for example, end up with separate hash entries for “7” and “ 7”. A more robust solution would be to capture the return code in the regex match:
++$errors{$1} if $row =~ / \Q$string\E \s* : \s* (\d+) $ /x;
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can't get hash keys to print
by Daren (Initiate) on Aug 24, 2015 at 15:08 UTC | |
|
Re^2: Can't get hash keys to print
by Daren (Initiate) on Aug 24, 2015 at 18:41 UTC | |
by AnomalousMonk (Archbishop) on Aug 24, 2015 at 19:20 UTC | |
by stevieb (Canon) on Aug 24, 2015 at 19:11 UTC | |
by Daren (Initiate) on Aug 24, 2015 at 19:20 UTC |