multi-dimensional arrays - more help please! 
Author Message
 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



Tue, 10 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. multi-dimensional arrays with hashes help please

2. help: multi-dimensional hash from flat array

3. Help with multi-dimensional array

4. Help understanding Lists of Lists or Multi-dimensional arrays

5. Help: Multi-dimensional arrays & such

6. Help with Multi-dimensional array

7. Need help with multi-dimensional arrays was:tie

8. arrays, multi-dimensional arrays, pointers and such

9. Associative arrays and multi-dimensional arrays.

10. Multi-Dimensional arrays, DBMs, and Assoc. Arrays

11. Extracting an array out of a multi-dimensional associative array

12. 2 dimensional array suntax help, please

 

 
Powered by phpBB® Forum Software