my ($file) = 'thefilename.txt'; open (FILE, ">$file") || die "Could not write to $file\n"; print FILE $stuff; close (FILE);