I am interested in creating a hash of hashes that will contain variables that are set by the user.
I have put this together to create a hash of a variable (population size, @total) that is sent into this subroutine. $tester is also sent into the array and is the number of populations that the user creates.
sub splitter { my %hasher = (); my $increase = 0; my $input = ""; while ($tester--) { $increase ++; push @key, $increase; } @hasher{@key} = @total; foreach $key (sort { $a <=> $b } keys %hasher) { print "Population #$key = $hasher{$key}\n"; } while () { print "Enter the population you will act on: "; chomp ($input = <STDIN>); $output = $hasher{$input}; #references a specific value in the + hash. print "$output BEFORE \n"; $output = $output + 8; print "$output AFTER\n"; $hasher{$input} = $output; #returns the modified value to the +hash foreach $key (sort { $a <=> $b } keys %hasher) { print "Population #$key = $hasher{$key}\n"; } return $output; } }
Later in the code, I take the $output value and turn it into an array that is modified, and i want to then return it to the hash in the following format:
A: Population number
1. Listing of individuals from 1…n (user defined) ie. @array = (1 … $population);
2. Listing of genetic marker associated with each individual (not yet coded)
The other thing I wanted to do, is be able to modify the arrays at the lower level of the hash, as I have done for my simple hash above. Something I have no idea how to do.
I have only been at this two weeks, and this is my first attempt at programming. Any help on any aspect of this post would be greatly appreciated. Thanks monks!
In reply to Hash of Hashes by BioNrd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |