my @ids; foreach my $a (@{ $names }) { push(@ids,$a->{id}); } my $ids = join(",", @ids);