Search notes:

Perl module File::Slurp

use warnings;
use strict;

use File::Slurp;

#
#  Read file into string (scalar context).
#
my $file_text=read_file(__FILE__); 
print $file_text;

#
#  Read file into array (list context).
#
my @file_lines=read_file(__FILE__); 
print join ". ", @file_lines;

#
#  Write a file (write this script in uppercase letters)
#
write_file('file.out', map { uc } @file_lines);
Github repository PerlModules, path: /File/Slurp/script.pl

write_file.pl

use warnings;
use strict;

use File::Slurp;

my $file_name = 'written_file.txt';

unlink $file_name if -f $file_name;

my @lines = (
  "foo bar baz\n",
  "one two three\n",
  "1 2 3 4 5 6 7 8 9\n"
);

write_file($file_name, @lines);
Github repository PerlModules, path: /File/Slurp/write_file.pl

sysread() is deprecated on :utf8 handles. This will be a fatal error in Perl 5.30 at /usr/share/perl5/site_perl/File/Slurp.pm line

Unfortunately, I got this error message when I used File::Slurp. When googling around about that, I found a few writers that said that File::Slurper should be used instead of File::Slurp.

See also

File::Slurper, Path::Tiny, IO::All, use Mojo::Util qw(slurp).
Perl modules
The .NET method System.IO.File::ReadAllText

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1741107149, '18.190.219.241', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/modules/File/Slurp/index(91): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78