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

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