my $out_fn = 'C:\\Program Files\\cron\\Cruise Ships\\ship_data.csv'; open(my $out_fh, '>', $out_fn) or die("Unable to create output file \"$out_fn\": $!\n"); ... print ($out_fh $input); ... $out_fh->print ( join(',', @$row), "\n");