open my $fh, ">FILENAME" or die "Can't write FILENAME: $!"; print $fh "We are writing a line of text to a file.\nSecond line"; close $fh;