get Hash of Array

E

ebm

is there an easier way to capture the values from a hash of an array?
here's what %data looks like if I use Dumper
---------------------------------------------------
%data using Dumper
$VAR1 = bless( {
'fnames' => [
'OwnerID',
'FaxDateTime',
'ElapsedTime',
'Pages'
],
'field' => {
'ElapsedTime' => 2,
'OwnerID' => 0,
'Pages' => 3,
'FaxDateTime' => 1
}
}
);

---------------------------------------------------------------

@keys = keys(%{$data->{'field'}});
@val = values (%{$data->{'field'}});

while(@keys){
$num = pop(@val);
$keyname = pop(@keys);
@k[$num]= $keyname;
}
This way the Key and the Value will be in the correct position of the
array. IE if Data->Field->ElapsedTime = array position 2.
Please let me know.

Thanks in advance.
 
B

Ben Morrow

Quoth ebm said:
@keys = keys(%{$data->{'field'}});
@val = values (%{$data->{'field'}});

while(@keys){
$num = pop(@val);
$keyname = pop(@keys);
@k[$num]= $keyname;
}

my @k;
my $field = $data->{field};
@k[values %$field] = keys %$field;

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,734
Latest member
manin

Latest Threads

Top