Write to a file



examples/files-perl/write_file.pl
#!/usr/bin/perl
use strict;
use warnings;

my $filename = "report.txt";
open my $fh, '>', $filename or die "Could not open file '$filename' $!";

my $title = "Report by: Foo Bar"; 
print $fh "$title\n";
print $fh "-" x length $title, "\n";

Writing to files with Perl