in reply to array of hashes
There must be a nicer way to lay out the dereferencing, someone anyone?#!/usr/bin/perl -w use strict; my $one = { 1 => 'mili', 2 => 'brown', 3 => 'kalu' }; my $sec = { 'age' => 23, 'eyes' => 'hazel', 'weight' => 128 }; my $thr = { 'name' => 'deep', 'roll' => 02, 'class' => 'BI' }; my @arr = ($one, $sec, $thr); my $ref = \@arr; for (my $i = 0; $i < 3; $i++) { while ( my($k,$v) = each %{$$ref[$i]} ) { print " $k " . '-> ' . $v . $/; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: array of hashes
by AnomalousMonk (Archbishop) on Feb 10, 2011 at 21:41 UTC |