in reply to Re: Issues with Array of Hashes
in thread Issues with Array of Hashes

Interesting that the above code doesn't kick out the error for you. Using the above code (including showing the ref of each):
use Modern::Perl; use Text::CSV::Slurp; use Data::Dumper; sub generate { my %inline; $inline{'total'} = 2; $inline{'items'} = [ { 'name' => 'item1' }, { 'name' => 'item2' } ]; return \%inline; } my $ref = &generate(); print Dumper( $ref->{'items'} ); print "\$ref->{'items'} is " . ref( $ref->{'items'} ) . "\n"; foreach my $item ( @{ $ref->{'items'} } ) { print $item->{'name'} . " is " . ref( $item ) . "\n"; } my $csv = Text::CSV::Slurp->create( input => $ref );
Gets the error for me on both mac and ubuntu boxes: Error on Mac:
$VAR1 = [ { 'name' => 'item1' }, { 'name' => 'item2' } ]; $ref->{'items'} is ARRAY item1 is HASH item2 is HASH Need an an array of hashes input to create CSV from at /usr/local/Cell +ar/perl/5.24.0_1/lib/perl5/site_perl/5.24.0/Text/CSV/Slurp.pm line 53 +.
And on Ubuntu box:
$VAR1 = [ { 'name' => 'item1' }, { 'name' => 'item2' } ]; $ref->{'items'} is ARRAY item1 is HASH item2 is HASH Need an an array of hashes input to create CSV from at /usr/local/shar +e/perl/5.22.1/Text/CSV/Slurp.pm line 53.