my $text_to_interpolate = ''; for my $i (0 .. $#system_names) { my ($color_0, $color_1) = ('#a1a1a1', '#f3f3f3'); $rowcolor = $i % 2 ? $color_1 : $color_0; $text_to_interpolate .= qq{ $system_names[$i] $name_names [$i] $menu_names [$i] $option_names[$i] $system_names[$i] Received }; } ... Data => qq| $text_to_interpolate ... |, ... #### my $string = "before @{[ code() . "stuff" ]} after";