如何在Mac下的perl中刷新文件?
我在远程 iMac 中有为 darwin-thread-multi-2level 构建的 perl v5.10.0
。我想运行一些 perl 脚本,该脚本打印一些数据并在每行输出后刷新。
- $file_handle->flush();
- 自动刷新$file_handle;
我已经在文件顶部使用 use IO::Handle;
尝试过这两个版本,但我得到的结果是 Can't located object method "autoflush" via package "FileHandle “
。
I have perl, v5.10.0 built for darwin-thread-multi-2level
in remote iMac. And I want to run some perl script which prints to file some data and flushes after each line of output.
- $file_handle->flush();
- autoflush $file_handle;
I have tried this two versions with use IO::Handle;
in top of the file, but the result I'm getting is Can't locate object method "autoflush" via package "FileHandle"
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您从哪里获取
$file_handle
?看起来它是一个 FileHandle 实例,而不是 IO::Handle 对象。您可以
在脚本的顶部尝试,而不是
IO::Handle
。或者,更改您的代码,使$file_handle
不再是FileHandle
实例。PS:你真的不应该运行 5.10.0,它有很多错误。 5.10.1 或更新的版本要好得多。
Where are you getting your
$file_handle
from? Looks like it's aFileHandle
instance, not anIO::Handle
object.You could try
at the top of the script, instead of
IO::Handle
. Alternatively, change your code so that$file_handle
is no longer aFileHandle
instance.PS: you really shouldn't be running 5.10.0, it's got quite a few bugs. 5.10.1 or anything newer is a lot better.
您确定“use IO::Handle;”吗?没有错别字吗?
在我看来该模块尚未加载。
Are you sure the "use IO::Handle;" doesn't have a typo?
It looks to me like the module hasn't loaded.
使用文件句柄;解决了我的问题。我在使用 Net::SCP::Expect 时遇到问题。这发生在 CentOS 6.3 下。
我收到如下错误:
-无法通过包文件句柄找到对象方法自动刷新
- 无法通过包文件句柄定位对象方法阻塞
use FileHandle; solved my issue. I was having issues with Net::SCP::Expect. This happened under CentOS 6.3.
I was getting errors like:
-can't locate object method autoflush via package filehandle
-can't locate object method blocking via package filehandle