The print was just there as an example - what is done
with those values is actually a little more complex.

I like using quoted hash keys because they show up
better in the syntax-aware editor I use.

I did try this before I sent the message, but in the
original block of code.  I think somehow in scaling
down the problem and taking it out of context I must
have eliminated the problem.  I didn't try just before
I sent, I just confirmed that the structure that had
worked in the overall context worked without it.

Thanks & regards,

   -John

--- "Jonathan E. Paton" <[EMAIL PROTECTED]>
wrote:
> > Did you try it?  You are right, the second foreach
> is totally redundant.
> > 
> > > foreach my $item ( @$cfgs )
> > > {
> > >     foreach my $inner ( $item )
> > >     {
> > >         print "$inner->{'dir'} : $inner->{'tpl'}
> : $inner->{'ext'} : $inner->{'rgx'}\n";
> > >     }
> > 
> > The only effect the second loop has is to rename
> $item to $inner.  Get
> > rid of it, and change $inner to $item in your
> print statement.
> 
> And also there is no need to quote hash keys, and if
> $inner is just a hash reference then the
> following is a shorter replacement:
> 
> print join (" : ", $_->{qw<dir tpl ext rgx>}) . "\n"
> for @$cfgs;
> 
> Whilst I'm not implication you *should* use this
> form, but to be aware it exists.  The main trick
> is to use a hash slice, E.g:
> 
> ($value1, $value2) = $hash{'key1', 'key2'};
> 
> is the same as:
> 
> ($value1, $value2) = ($hash{key1}, $hash{key2});
> 
> Naturally I haven't tested, but it should be okay...
> should... :P
> 
> Jonathan Paton
> 
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to