in reply to Re: Writing to a new file with a dynamically created name
in thread Writing to a new file with a dynamically created name

That code would be much better as:

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; }

... and you could even golf it further, but that's a decent balance of simplicity and clarity and safety.