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

Re: [MacPerl] IO:: problems



I'm away from my desktop machine and 5.14a2 this week, so I probably won't
be of much help here, but have we seen *anyone* asking about FileHandle
before now actually REPORT THE ERROR MESSAGE that they get yet from WHICH
VERSION of MacPerl???  This is the first one, I think, and it always helps.
These have almost been the classic "My script doesn't work.  Can anyone
help me?" that you see so often on Usenet.

I think I may know what's going on, and if I'm right, the solution is in
ftp://mors.gsfc.nasa.gov/pub/MacPerl/Scripts/Fixed_Library_Routines/.

"Ramesh-CRR026 Ramakrishnan" writes:
}Hi!
}
}Replaced by IO::Handle & Co.? Just tried to change my FileHandle code to
}IO::Handle, but it doesn't act according to the documentation. The
}documentation says I can open a file by adding the file name as a parameter
}to the new method, but examining the code shows that the new method only
}accepts one parameter, the class name. It doesn't have a open method either,
}again contradicting the documentation.

The documentation was in error in 5.002.  This was reported to the author
and it's fixed in 5.004.  The open method is in IO::File.

But as I reported here, there was a buglet in IO::File as distributed in
the first beta, which Matthias fixed in the latest, 5.14b2.  If you used
IO::File before the fix, inevitably it would prepend a ./ to the filename,
which would cause your open to fail.

This bug was also in the IO::File and FileHandle in 5.13r2, which is why I
have both in my Fixed_Library_Routines directory.  Here's the diff for
FileHandle.pm:

290c290,291
<         $file = "./" . $file unless $file =~ m#^/#;
---
> #       $file = "./" . $file unless $file =~ m#^/#;
>         $file = ":".$file unless $file =~ m#^\S#;


}
}Next I tried the IO::File module. It opened my files which are in the current
}directory easily, but any file names that have paths embedded in them are not
}opened. The error message is "# No such file or directory". If I change the

Because it stuffed a ./ at the beginning, and there's "no such file or
directory".

}":" in the path to "/", it complains that the "# File name too long" for

And that one began with / and was > 32 characters long?

}files inside folders in the HD but "# No such file or directory" for files in
}the root level of the HD.
}
}Here's my test code:
}
}#!perl -w
}
}use IO::File;
}
}print "Droped @ARGV\n";
}$FileName = $ARGV[0];
}# Uncomment the following to change ":" to "/"
}#$FileName =~ s/:/\//g;
}print "FileName = " . $FileName . "\n";
}$File = new IO::File "$FileName", "r" or die $!;
}print "FileRef = " . ref($File) . "\n";
}print $File->getline . "\n";
}$File->close;
}
}I made this code a droplet in my testing. Just change IO::File to IO::Handle
}to test the IO::Handle code.
}
}I'm running MacPerl 5.1.3r2. I hope <shudder> I'm not running an old version
}of the library.
}
}Best regards,
}Ramesh
}
}_______________________________________________________________________________
}I'd have to look at the details. FileHandle does not really
}exist anymore, it is now replaced with IO::Handle & Co., but
}some backwards compatibility should exist.
}
}What is the message you get?
}
}
}Matthias
}
}***** Want to unsubscribe from this list?
}***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch


--------
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693
Greenbelt, MD 20770
schinder@pjstoaster.pg.md.us


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch