$output_str = "@subject[$j];@failed[$j];@monthi[$j]/@dayi[$j]/@yeari[$j];@routerval[$j];" . "@tag[$j];@montho[$j]/@dayo[$j]/@yearo[$j];@lotCode[$j];@commentso[$j]\n"; # or, if you've gone to scalars $output_str = "$subject;$failed;$monthi/$dayi/$yeari;$routerval;" . "$tag;$montho/$dayo$/$yearo;$lotCode;$commentso\n"; print OUTPUT $output_str; print $output_str;