in reply to Re^5: how to sum over rows based on column headings in perl
in thread how to sum over rows based on column headings in perl

Hmmm ... I am not very comfortable with interpreting $_. I don't know how to print $masks{$_} to understand what it is. That is my problem. I know I am dumb!

print $name."\n"; print $letters."\n"; print $masks{$_}."\n";
which gives obvious error: A W W M W W W M Use of uninitialized value $_ in hash element at ./parse-counts.pl lin +e 37, <INPUTR> line 2. Use of uninitialized value within %masks in concatenation (.) or strin +g at ./parse-counts.pl line 37, <INPUTR> line 2.

Replies are listed 'Best First'.
Re^7: how to sum over rows based on column headings in perl
by Anonymous Monk on Jul 31, 2015 at 20:09 UTC

    Replace

    $counts{$name}{$_} += ($masks{$_} | $letters) =~ /M/ for @unique;

    with

    for my $label (@unique) { print "$masks{$label} | $letters\n"; $counts{$name}{$label} += ($masks{$label} | $letters) =~ /M/; }

    This will allow you to see what you are or'ing