Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Now, the question is how to assign data to this...my %hash = ( 'this_type' => { 'field1' => { REQ => 'N', POS => 34, LENGTH => 10, data => ' ' x 10, FILTER => \&default_filter() } }, 'that_type' => { 'field1' => { REQ => 'Y', POS => 34, LENGTH => 10, data => ' ' x 10, FILTER => \&default_filter() }, 'field2' => { REQ => 'Y', POS => 35, LENGTH => 10, data => ' ' x 10, FILTER => \&default_filter() }, }, # and a lot more records... );
Should I simply assign like this:@$hash{$type}->{@sorted_keys}->{data} = @mydata;
Lfor my $k (@sorted_keys) { $hash{$type}->{$k}->{data} = shift @mydata; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash assignment in complex structure
by borisz (Canon) on Apr 17, 2005 at 18:18 UTC | |
|
Re: hash assignment in complex structure
by tlm (Prior) on Apr 17, 2005 at 18:26 UTC | |
|
Re: hash assignment in complex structure
by davidrw (Prior) on Apr 17, 2005 at 18:15 UTC |