in reply to Arrays not being manipulated

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.

I don't think that's what you want!?
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

Replies are listed 'Best First'.
Re^2: Arrays not being manipulated
by aristotle73 (Sexton) on Jan 01, 2005 at 20:29 UTC
    Could you please explain to me why it is better to declare the variables with my instead of using our? Thx for all the help everyone :D
        Ok, thanks :D It makes alot more sense now ^_^