hsinclai has asked for the wisdom of the Perl Monks concerning the following question:
| Array 1 | Array 2 | Array 3 | Array 4 |
| hostname1 | 1.2.3.5 | 5.3.2.1.in-addr.arpa | 131 days |
| hostname2 | 11.22.33.55 | 55.33.22.11.in-addr.arpa | 128 days |
| hostname3 | 22.21.20.55 | 55.20.21.22.in-addr.arpa | 366 days |
#!/usr/bin/perl -w use strict; use Data::Dumper; my @ns_list = ( 'server1.foo-domain.net', 'server2.noo-domain.net', 'server3.zoo-domain.net', ); my @addr_list = ( '1.2.3.5', '11.22.33.55', '22.21.20.55', ); my @ptr_list = ( '5.3.2.1.in-addr.arpa', '55.33.22.11.in-addr.arpa', '55.20.21.22.in-addr.arpa', ); my @uptime_list = ( '131 days', '28 days', '366 days', ); my %ns_records = map { $_ => [ shift @addr_list, shift @ptr_list, shift @uptime_list ] } @ns_list; my $d; foreach my $k ( keys %ns_records ) { print "\n$k:"; for ( $d = 0; $d <= $#{$ns_records{$k}}; $d++ ) { print "\n ", @{$ns_records{$k}}->[$d]; } print $/; } print $/; __END__ print Dumper \%ns_records; $VAR1 = { 'ns0.foo-domain.com' => [ '1.2.3.5', '5.3.2.1.in-addr.arpa', '131 days' ], 'ns0.baz-domain.org' => [ '22.21.20.55', '55.20.21.22.in-addr.arpa', '366 days' ], 'ns0.bar-domain.net' => [ '11.22.33.55', '55.33.22.11.in-addr.arpa', '28 days' ] };
when printing out the result, but the code still runs with Perl 5.8.1. I'd like to be able to dereference the array inside the HoA without error."Using an array as a reference is deprecated"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Constructing a HoA from 4 separate arrays
by davido (Cardinal) on Oct 18, 2004 at 03:07 UTC | |
by hsinclai (Deacon) on Oct 18, 2004 at 03:18 UTC | |
|
Re: Constructing a HoA from 4 separate arrays
by Zaxo (Archbishop) on Oct 18, 2004 at 03:21 UTC | |
by ikegami (Patriarch) on Oct 18, 2004 at 06:16 UTC | |
by hsinclai (Deacon) on Oct 18, 2004 at 03:43 UTC | |
|
Re: Constructing a HoA from 4 separate arrays
by tmoertel (Chaplain) on Oct 18, 2004 at 04:31 UTC | |
|
Re: Constructing a HoA from 4 separate arrays
by ihb (Deacon) on Oct 18, 2004 at 06:48 UTC | |
|
Re: Constructing a HoA from 4 separate arrays
by TedPride (Priest) on Oct 18, 2004 at 05:30 UTC | |
by davido (Cardinal) on Oct 18, 2004 at 05:38 UTC |