2

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.

  1. $file_handle->flush();
  2. 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".

Mihran Hovsepyan
  • 10,810
  • 14
  • 61
  • 111
  • did you mean $file_handle->autoflush(); ? Or maybe you should give that a try. Just for grins, I would pass an explicit argument of 1 even though it's supposed to default to true when called... – Mike Ellery May 06 '11 at 23:37

3 Answers3

3

Where are you getting your $file_handle from? Looks like it's a FileHandle instance, not an IO::Handle object.

You could try

use FileHandle;

at the top of the script, instead of IO::Handle. Alternatively, change your code so that $file_handle is no longer a FileHandle 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.

mscha
  • 6,509
  • 3
  • 24
  • 40
2

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

2

Are you sure the "use IO::Handle;" doesn't have a typo?

It looks to me like the module hasn't loaded.

Rich Parker
  • 172
  • 5