in reply to replacing order element in array

Yet another (more perl-ish) way to do it :
my @a = (1,2,3,4,5,6); my @b=(1,5,3,6,8,2,4); my %aref = map {$_=>\$_} @a; my $cand; # Candidate value to replace the selected value exists ($aref{$_}) or $cand=$_,last for @b; ${$aref{3}}=$cand; # Assuming you want the value "3" replaced print @a; #--Output -- #128456

     "Choose a job you like and you will never have to work a day of your life" - Confucius