in reply to store value from AoHoH into a scalar

You say you have an array (@t_loop), but you dumped a hash ref. If you did print(Dumper(@t_loop)), you should have done print(Dumper(\@t_loop)) so we can see the entire structure. Dumper expects a list of *scalars*.

Your code is actually already correct for the second dump. The following will handle both data structures you presented:

foreach (@t_loop) { my $label = $_->{label}; my $value; if (exists($_->{value_loop})) { $value = join(' ', map { $_->{value} } @{$_->{value_loop}); } else { $value = $_->{value}; } $final .= "$label=$value\n"; }

It's complicated, but that's because your data structure is needlessly complex.

%t_loop = ( Dow => [ 'Sun', 'Mon', 'Tue', 'Wed' ], );
%t_loop = ( UK => 'Country', );
while (my ($key, $val) = each %t_loop) { $val = join(' ', @$val) if ref $val; $final .= "$key=$val\n"; }
Update: oy! My initial code was very wrong.