Mike Liss wrote:
>
> Ok,
>
> I think I am beginning to see the light...
> but I am still in the dark on this one...
>
> How would I iterate over these arrays?
>
> $MyArray[0][0][0] = "A 1";
> $MyArray[0][1][0] = "comment 1";
>
> $MyArray[0][0][1] = "A 2";
> $MyArray[0][1][1] = "Comment 2";
>
> $MyArray[1][0][0] = "B 1";
> $MyArray[1][1][0] = "comment 1";
>
> $MyArray[1][0][1] = "B 2";
> $MyArray[1][1][1] = "Comment 2";
>
>
> for example I could do this:
>
> for( $i=0; $i<$n; $i++ )
> {
> for( $j=0; $j<$m; $j++ )
> {
> for( $k=0; $k<$p; $k++ )
> {
> print " $MyArray[ $i ][ $j ][ $p ] \n" ;
> }
> }
> }
>
> But the problem with that is I don't know what n, m, and p are going to
> be...
You mean something like this:
my @MyArray = ( [ [ 'A 1', 'A 2' ], [ 'comment 1', 'Comment 2' ] ],
[ [ 'B 1', 'B 2' ], [ 'comment 1', 'Comment 2' ] ] );
for my $i ( 0 .. $#MyArray ) {
for my $j ( 0 .. $#{$MyArray[$i]} ) {
for my $k ( 0 .. $#{$MyArray[$i][$j]} ) {
print " $MyArray[ $i ][ $j ][ $k ] \n";
}
}
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]