What could be wrong here?
I am trying to display the content of an existing file:
perl -MFile::Slurp -e 'print File::Slurp->read_file("/tmp/001.jpg", { binmode => ":raw" } ) if -e "/tmp/001.jpg"; '
and I get the error:
read_file 'File::Slurp' - sysopen: No such file or directory
The file exists, the print gets executed only if -e "/tmp/001.jpg"
Call the function via
File::Slurp::read_fileinstead ofFile::Slurp->read_file. In the latter case Perl’s object system comes into play, and the first argument passed toread_filewill be the thing before the->— meaning its first argument will be the string"File::Slurp"instead of the file name you actually want to read.That’s also why you call
newon the packages you want to create a new instance from.