in reply to Constructing a HoA from 4 separate arrays

You can do that by working with the indexes, rather than shifting

my %ns_records = map { $ns_list[$_] => [ $addr_list[$_], $ptr_list[$_], $uptime_list[$_] ] } 0 .. $#ns_list;
That is non-destructive of your original data.

A small point of style. The _list suffixes on your arrays don't add much to the readability of your code. I would drop them in favor of descriptive plurals like @addrs, @ptrs, @uptimes. Your hash would read better with a singular name, $ns_record{'foo.org'} pronounced "ns_record of foo.org".

The warning should have a line number associated with it. I think it is from line 33, @{$ns_records{$k}}->[$d], which should be $ns_records{$k}->[$d].

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Constructing a HoA from 4 separate arrays
by ikegami (Patriarch) on Oct 18, 2004 at 06:16 UTC
    Your hash would read better with a singular name, $ns_record{'foo.org'} pronounced "ns_record of foo.org".

    By that logic, arrays should be singular as well, because $addr[4] is pronounced "address number 4". Some consistency would be nice.

    For hashes, I use plural when they're used as an array, and singular when they're used as a structure: %ns_records would be a list of records ($ns_records{$domain}), while %ns_record would be a record with named fields ($ns_record{'ptr'}).

Re^2: Constructing a HoA from 4 separate arrays
by hsinclai (Deacon) on Oct 18, 2004 at 03:43 UTC
    Thanks for the tips - any errors are so glaring after you guys point them out!

    ...that is non-destructive of your original data.
    That is very instructive!