[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] IO::Handle



I am puzzled.  In the synopsis for IO::Handle it gives the following example:

    use IO::Handle;

    $fh = new IO::Handle;
    if ($fh->open "< file") {
        print <$fh>;
        $fh->close;
    }

Even if you correct the syntax error, it doesn't work.  There is no open
method defined for this class, and the autoloader cannot find one.  (I am
using MacPerl5.10r2, standalone 68k version, both Big and ordinary, and the
latest version 1.14 of IO::Handle.)  Is it supposed to autoload something,
which is not present in my set-up (does autoloading only work on
PowerMacs?), or is the documentation just out of date (there was an open
method which worked fine with the old FileHandle class)?
You can work round it by just calling open as an ordinary function:
    $fh = new IO::Handle;
    if (open ($fh, "< file")) {
      print <$fh>;
      $fh->close;
    }
but this seems very strange to me...why should close and everything else be
a method if open is not?

I would be grateful if anyone could enlighten me as to whether this is a
MacPerl problem, a feature of the module, or some misconception of mine.

Thanks.