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

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.

Replies are listed 'Best First'.
Re^4: how to set a value for a hash reference
by AWallBuilder (Beadle) on Mar 14, 2012 at 13:34 UTC

    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.