Ok, then next question. My situation is that I have a set of data that I would like to access both in an array, and in a hash. Basically the fields have both an ordinal reference, and a named reference. Is there a way to link a data set to both a hash and an array.
Lets say this is my array.
my @array=(Bob, Smith, 1234 Main St, Anytown, 20500);
Or this is my hash.
my %hash=( firstname => Bob, lastname => Smith, address => 1234 Main St, town => AnyTown, zip => 20500);
I can access the information from either one.
print "His name is $array[0] $array[1]\n;
or
print "His name is $hash[firstname] $hash[lastname]\n;
But if I change one the other will, of course, not change.
$array(0)="Robert" print "His name is $hash[firstname] $hash[lastname]\n; #wrong result
Is there a way to tie these two data structures together?
Thank you,
Skip
In reply to Link a hash and an array by SkipHuffman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |