my $num = 4; my @records = ( { bytes => 'foo0'}, { bytes => 'foo1'}, { bytes => 'foo2'}, { bytes => 'foo3'}, ); my @results; for (1 .. $num) { push (@results, [ $records[$_]->{bytes} ]); } @results = get_bytes($num); print Dumper (\@records); sub get_bytes { my $num = shift; my @ret; push (@ret, $_) for 1 .. $num; return @ret; } -------------- $VAR1 = [ { 'bytes' => 'foo0' }, { 'bytes' => 'foo1' }, { 'bytes' => 'foo2' }, { 'bytes' => 'foo3' }, {} ];