in reply to Re: random pairs
in thread random pairs
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: random pairs
by CountZero (Bishop) on Jul 16, 2012 at 22:30 UTC | |
by Anonymous Monk on Jul 19, 2012 at 16:43 UTC | |
by CountZero (Bishop) on Jul 19, 2012 at 19:41 UTC |