Perlfunc: file_put_contents()
PHP has a really handy function called file_put_contents()
that simplifies writing to a file. I did a quick Perl version of that function for my scripts.
sub file_put_contents {
my ($file, $str) = @_;
open (my $fh, ">", $file) or return undef;
print $fh $str or return 0;
close $fh;
return length($str);
}