my @content = map {$_->content} @responses; #### my @content = map { escape_html(convert_newlines($_->content)) } @responses; #### my @content = map { my $content = $_->content; convert_newlines($content); escape_html($content); $content; } @responses; #### my $parts = [ 'Part1', 'Part2','Part3' ]; my $newLoop; for (@$parts) { my $hash = { PARTNAME => $_ }; $hash->{SELECTED}++ if $_ eq $row->{title}; push @$newLoop, $hash; } # ---- my $parts = [ 'Part1', 'Part2','Part3' ]; my $newLoop = [ map {{ PARTNAME => $_, $_ eq $row->{title} ? (SELECTED => 1) : () }} @$parts ];