my @comment_cols = qw/title author thread_id id/; for (@comments) { my %data; @data{@comment_cols} = $_->get(@comment_cols); push @c_data, \%data; } #### my %comment_cols = qw/ c_title title author author id thread_id c_id id /; for (@comments) { my %data; @data{keys %comment_cols} = $_->get(values %comment_cols); push @c_data, \%data; } #### @c_data = map { my %data; @data{keys %comment_cols} = $_->get(values %comment_cols); \%data; } @comments;