Tud*_*tin 1 perl readfile fileslurp
这可能有什么问题?
我试图显示现有文件的内容:
perl -MFile::Slurp -e 'print File::Slurp->read_file("/tmp/001.jpg", { binmode => ":raw" } ) if -e "/tmp/001.jpg"; '
Run Code Online (Sandbox Code Playgroud)
我收到错误:
read_file 'File::Slurp' - sysopen: No such file or directory
Run Code Online (Sandbox Code Playgroud)
该文件存在,print
仅执行获取if -e "/tmp/001.jpg"
通过File::Slurp::read_file
而不是调用函数File::Slurp->read_file
.在后一种情况下,Perl的对象系统发挥作用,传递给的第一个参数read_file
将是之前的事物->
- 意味着它的第一个参数将是字符串"File::Slurp"
而不是您实际想要读取的文件名.
这也是您调用new
要从中创建新实例的包的原因.
归档时间: |
|
查看次数: |
1126 次 |
最近记录: |