in reply to Re^2: Can't get hash keys to print
in thread Can't get hash keys to print

Something else isn't right then. Using the data you supplied above (which you should copy to your actual question for future readers), and copy/pasting Athanasius' regex, here's what I get in %errors:

use warnings; use strict; my $string = "Return code is"; my %errors; while (<DATA>){ ++$errors{$1} if /\Q$string\E \s* : \s* (\d+) $ /x; } while (my ($k, $v) = each %errors){ print "$k: $v\n"; } __DATA__ 2015/04/06 12:38:15 (9):(5564) Return code is :55 2015/04/06 12:38:15 (9):(6600) Return code is :55 2015/04/06 12:41:31 (9):(3604) Return code is :1

Output:

1: 1 55: 2

Replies are listed 'Best First'.
Re^4: Can't get hash keys to print
by Daren (Initiate) on Aug 24, 2015 at 19:20 UTC
    I think it's the format of the input file. (UNIX)
    I removed the $ from the regex and it works fine.
    I don't quite understand why though.