Restating...
I want it to compare each element ($currentMutation) in the @numberMutation array to each element in the @organism array
and set the @organism[$i] = $currentMutation if (@organism[$i] < $currentMutation)
The @organism array is preset to all 1's.
Given this logic, ALL the elements of @organism will always be set to the highest value of $currentMutation.
use strict; ## Simplified for testing my @numberMutation = (); while (<DATA>) { chomp; @numberMutation = split(//,$_); } my @organism = (1,1,1,1,1,1,1,1,1); foreach (@numberMutation) { my $currentMutation = $_; my $i = 0; foreach (@organism) { if ($_ < $currentMutation) { $organism[$i] = $currentMutation; $i++; } } } print "ORG: @organism\n"; ## prints ORG: 9 9 9 9 9 9 9 9 9 print "MUT: @numberMutation\n"; __DATA__ 31415926535897932384626433832
In reply to Re: Arrays not being manipulated
by nedals
in thread Arrays not being manipulated
by aristotle73
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |