my $output = ''; for ( ... ) { $output .= "$file:$@$filer_hash{$filer}},"; } print "Now have: $output\n";