The first part is just creating 3d arrays "biu(i,j,k)" and "ziu(i,j,k)" and setting all the entries to 105 and 15 respectively. If I leave out all the statements after the comment problem ?, it prints out the arrays just as I expected. However, I am trying to change certain array locations to different values, as in the statments following the problem ? statement. It changes all the $i values for $biu in the rows ($j=4 and $j=23) versus just the $i values in the for statements. I believe I am missing something big on the understanding of how arrays work in perl, as I am still thinking in fortran terms. Do I need to make all the $i into my $i ? Thanks in advance$u15 = 15; $u105 = 105; $u25 = 25; # for($k=0; $k<=12; $k++) { push @biu_z, $u105 ; } for ($j=0; $j<=26; $j++) { push @biu_yz, [ @biu_z ]; } for ($i=0; $i<=26; $i++) { push @biu, [ @biu_yz ]; } # for($k=0; $k<=12; $k++) { push @zcu_z, $u15 ; } for ($j=0; $j<=26; $j++) { push @zcu_yz, [ @zcu_z ]; } for ($i=0; $i<=25; $i++) { push @zcu, [ @zcu_yz ]; } # # problem ? # for ($k=1; $k<=12; $k++) { # for(my $i=1; $i<=5; $i++) { $biu[$i][4][$k] = $u25; } for(my $i=22; $i<=26; $i++) { $biu[$i][4][$k] = $u25; } for($i=1; $i<=4; $i++) { $biu[$i][23][$k] = $u25; } for($i=23; $i<=26; $i++) { $biu[$i][23][$k] = $u25; } # }
In reply to Help with multi-dimensional arrays (list of lists) by pattobw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |