[Petal] repeat through hash

Peter Rabbitson rabbit at rabbit.us
Thu Apr 20 02:34:04 BST 2006


On Wed, Apr 19, 2006 at 05:52:00PM -0700, Corey wrote:
> 
> Is there any particular technical reason why the 'repeat' syntax can't/won't 
> loop through hashes, as though passed to, say, the perl 'keys' or 'values' 
> function, or something similar to 'for ( %{ $hash } ) { return $_ }'?
> 
> It seems rather limiting to only be able to iterate/loop through arrays or
> arrays of hashes - I'm constantly finding that I have to design my libraries' 
> data-structures around Petal; for instance, using arrays of hashes 
> rather than plain hashes which are often more natural and appropriate.
> 
> Thanks,
> 
> Corey
> 

What you probably need is the each: function provided by Petal::Utils.

Cheers


More information about the Petal mailing list