in reply to array naming
The difference is that instead of using numbers to get at elements of the array, you use text. Suppose you had a file like the following:
You might read it in and put it in the hash as in this snippet:location=dungeon name=corwin weapon=grayswandir
You'll end up with $data{name} set to 'corwin' and so forth.my %data = (); # initialize hash while (<INPUT>) { # assume you have the file open already my ($key, $value) = split(/=/, $_, 2); $data{$key} = $value; }
Update: If you want to keep an actual array around, you can put a reference in a hash. See perlref and perldsc for more details:
or some such nonsense.$data{$arrname} = \@array; # or $data{$arrname} = [ @array ];
|
|---|