use Modern::Perl; use autodie; open my $in_fh, '<', 'Datafile.txt'; while (<$in_fh>) { my ($outfile, @extra) = split /,/, $_; open my $out_fh, '>', "$outfile.html"; print $out_fh @extra; }