in reply to Re: Syntax for partly associative arrays
in thread Syntax for partly associative arrays
but I don't know how to set $firstval to see that. I understand the idea of arrays and references (is a hash an array of references?), but I know only by rote when to use @, $, and % for arrays (and %$ is new to me). So does this mean that anytime a multidimensional array is partly associative, I have to use foreach for all loops on it? I thought there was a way to use for $i (1..n) for the numerical variables and foreach for the others, but I don't remember it. Phil Rennert#!/usr/bin/perl $a[1]{"blue"}=1; $a[1]{"red"}=2; $a[2]{"blue"}=3; $a[2]{"red"}=4; foreach $hash (@a) { foreach $word (keys %$hash) { print $firstval." ".$word." ".$hash->{$word}."\n"; } } I'd like to see 1 blue 1 1 red 2 2 blue 3 2 red 4
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Syntax for partly associative arrays
by Anonymous Monk on Sep 08, 2003 at 14:43 UTC |