
multi-dimensional arrays - more help please!
I have loads of data files that I need to sort.
Here is one data file:
name:chris:
age:27:
sex:male:
What I do, for easy access, is to load in the file and then turn it into a hash array like so:
close FILE;
($left,$right)=split(/:/,$line);
$DATA{$left}=$right;
}
I have a loop to do this for all the files, but what if I only want cirtain files depending on their content like so:
$counter=0;
open(FILE,$file);
close FILE;
undef $DATA;
($left,$right)=split(/:/,$line);
$DATA{$left}=$right;
}
if($DATA{'age'}<20){
$NEWARRAY[$counter++]=$DATA; # THIS LINE IS WRONG - HOW DO I DO IT?
}
}
foreach $key (keys %NEWARRAY[$loop]){ #AND HERE
print "$NEWARRAY[$loop]{$key}\n\n"; #AND HERE
}
}
Oh dear, I know what I want to do, but its the right syntax I want.
I wont hastle any more after this one!
Chris D