That is close, but not exactly what I want to do.
I did not put enough detail in my starting post.
I have an array of values, the first one of which indicates what sort of data is in the array. I also have a set of arrays that indicate what fieldnames should be associate with the array.
Think of the array as sometimes being name and address, and sometimes name and phone number. I want to read $ARRAY[0] and then decide how the hash will be created. What I tried to do that does not work is this:
But, of course, that does not work exactly like that, so I am trying to get close. Skip@Address=qw(type firstname lastname streetaddress city zip); @Phone=qw(type name phonenumber); %Stuff; sub ReadStuff{ if ($@_[0]='addr') {%Stuff(@Address)=@_}; elsif ($@_[0]='phone'){%Stuff(@Phone)=@_}; ...do something useful... } @data=(addr, bob, smith, 1234 main st, anytown, 20500); &ReadStuff(@data); @data=(phone, bob, smith, 212-555-1212) &ReadStuff(@data)
In reply to Re: Re: Link a hash and an array
by SkipHuffman
in thread Link a hash and an array
by SkipHuffman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |