1package Petal::Utils::Each;
2
3use strict;
4use warnings::register;
5
6use Carp;
7
8use base qw( Petal::Utils::Base );
9
10use constant name    => 'each';
11use constant aliases => qw();
12
13our $VERSION  = ((require Petal::Utils), $Petal::Utils::VERSION)[1];
14our $REVISION = (split(/ /, ' $Revision: 1.2 $ '))[2];
15
16sub process {
17    my $class = shift;
18    my $hash  = shift;
19    my $args  = shift || confess( "'each' expects a hash ref (got nothing)" );
20
21    my $result = $hash->fetch( $args );
22
23    confess( "1st arg to 'each' is not a hash ($args = $result)!" )
24      unless ref($result) eq 'HASH';
25
26    return [ map { { key => $_, val => $result->{$_} } } keys %$result ];
27}
28
29
301;
31
32__END__
33
34# Return a list of key/value pairs for a hashref
35