in reply to Re: how to set a value for a hash reference
in thread how to set a value for a hash reference

thank you for the details and the loop suggestion. The "//" means if for a and b overlap doesn't exist then it equals zero, right?

But where would I put this line? after the loop? no -> between the $a and $b? would I have to embed it in a loop with a and b being all elements of members?

  • Comment on Re^2: how to set a value for a hash reference

Replies are listed 'Best First'.
Re^3: how to set a value for a hash reference
by moritz (Cardinal) on Mar 14, 2012 at 13:19 UTC
    The "//" means if for a and b overlap doesn't exist then it equals zero, right?

    Correct. It's the "defined-or" operator.

    But where would I put this line? after the loop?

    Wherever your read the values of $overlap.

      hmmm - I guess its a bit complicated because I"m just passing the entire hash reference to another script that writes the output in a nice matrix format. And I don't want to modify "write_R_matirx". any other suggestions?

      use Smash::Utils::MatrixIO qw(:all); my $SMASH_overlap_file="$CDHIT_file.smash.overlap"; write_R_matrix($SMASH_overlap_file,$overlap);

        Then you do need the initialization. You could write something along the lines of

        for my $a (@members) { for my $b (@memebers) { $overlap->{$a}{$b} = 0; } }

        before the other loop.