use IO::File; format TEXTFORMAT = @<<<<<<<<<<<@>>>>>>>>>>>>>>> $text1 $text2 . $text1 = "Hello"; $text2 = "there!"; $filehandle = new IO::File; $filehandle->open(">yourFile.txt") or die "Cannot open format.txt"; $filehandle->format_write (::TEXTFORMAT); $filehandle->close;