timothy adigun [2teezp...@gmail.com] wrote: >#!/usr/bin/perl >use warnings; >use strict; > >my @wanted = qw( dad mum children); >my @children = qw(tim dan mercy); >my $ref = { > dad => "mick", > mum => "eliz", > children => { first => 'tim', second => 'dan', third => 'mercy', }, >}; > >foreach my $cell (@wanted) { > print STDOUT "$cell:"; > if ( defined keys %{$ref} ) { > print STDOUT $ref->{$cell}, "\n" if !ref( $ref->{$cell} ); > if ( ref( $ref->{$cell} ) ) { > foreach my $child ( keys %{ $ref->{$cell} } ) { Tim: How is it the first time the print below produces: children:tim and the 2nd time just prints dan for $ref->{$cell}{$child} when it looks like all that happened is the value of $child changed from 'first' to 'second' ? > print STDOUT $ref->{$cell}{$child}, "\n\t"; > } > } > } >} > >*OUTPUT* > >dad:mick >mum:eliz >children:tim > dan > mercy > Thanks, David
This communication is confidential. Frontier only sends and receives email on the basis of the terms set out at http://www.frontier.com/email_disclaimer. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/