in reply to Write to different file name
$text = "file1.txt"; open (DAT,">file2.txt"); print DAT "$text\n" or die $!; [download]
Courage, the Cowardly Dog