Let's say I used your bit of code and edited it a bit to match my needs. Currently I have this:
my %test; my @predetermined; my @results; @predetermined = (0..$pop-1); for my $element (@predetermined) { my $pair; { $pair = int(rand($pop)); redo if $test{$element.'-'.$pair} or $test{$pair.'-'.$elem +ent} or $pair == $element; } $test{$element.','.$pair} = $test{$pair.','.$element} = 1; push @ {$pop{$element{interactions}}}, $pair; push @results, $element.'-'.$pair; foreach (@results) { ($element.','.$pair) = split; $element{$_} = $element; } } sort {$a <=> $b} @results; say for (@results);
For the line of code below,
push @ {$pop{$element{interactions}}}, $pair;
the terminal keeps returning this.
Use of uninitialized value $element{"interactions"} in hash element at disease_outbreak_array.pl line 87, <> line 1. I have this hash that contains hashes of hashes that follow this format:my %pop = ( 0 => {status => "0", interactions => []}, 1 => {status => "0", interactions => []},
I am attempting to store all the values that one person decides to interact with inside the "interactions" list within my hash of hashes, but it keeps giving me the uninitialized error. TIA
In reply to Re^2: random pairs
by Anonymous Monk
in thread random pairs
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |