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

No, the heart of the algorithm is the or operator, and changing M to MUTS breaks alignment that allows the or operator to work properly.

Print out both sides of the or operator to see the misalignment.

  • Comment on Re^5: how to sum over rows based on column headings in perl

Replies are listed 'Best First'.
Re^6: how to sum over rows based on column headings in perl
by angerusso (Novice) on Jul 31, 2015 at 19:58 UTC

    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.

      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