REQUEST: Problem with Perl (Win32) on Windows98SE and reading files

J

Jeff

Hi all

I don't usually follow these groups so replies to my email
(jeffcrow(AT)tpg.com.au) would be preferred in addition to posts to the
group. Thanks.

I am having problems reading a file from a perl script running under
windows98se. This seems to be a recent problem as I've had several scripts
in the past work fine. The general flow of data is;

Data in a spreadsheet in OpenOffice.org 1.1 is output as text file to a dir.
A perl script is kicked off to read all files in the dir and process the
data for output as webpages. I was trying to read files in a dir in a
scalar context but when I was having problems I changed to an array context.
A snip of code is now;

opendir(OUTDOOR, "${autodir}") || die "Can't open the dir ${autodir}";
@files = readdir(OUTDOOR);
closedir(OUTDOOR);
foreach $file (@files) {
TEST READABLE
IF !READABLE
CHANGE MODE TO READABLE OR DIE WITH ERROR MESSAGE
}

What I get as output is 'File is not readable and permissions can't be
changed'. I have checked the directories in the path (\auto\process0) to
ensure they are visible and readable. I have checked the files in the dir
are visible and readable. I have opened the files in a text editor and they
are readable and plain text. I have opened a console/MS-DOS Prompt window
and opened the file with "edit test.out" and viewed the contents fine.

I wrote a perl script that creates some file in the directory and puts some
text into the file. I then close the file, sleep for 30 seconds and then
readdir(directory) and again the files are reported as NOT readable and
permissions can't be changed. Again, the file I output is fine and readable
in consoles, editors etc.

I deleted the version of perl I was using (Activestate 5.?? I can't recall)
cleaned the REGISTRY and installed a GNU perl 5.004_02 and still the same
problem.

Short of running this under LINUX as I would ordinarily do, can any win32
Perl guru offer any assistance?

Thanks in advance for any and all for assistance provided.
Jeff
 
J

Jay Tilton

"Jeff" <jeffcrow(AT)tpg.com.au> wrote:

: opendir(OUTDOOR, "${autodir}") || die "Can't open the dir ${autodir}";
: @files = readdir(OUTDOOR);
: closedir(OUTDOOR);
: foreach $file (@files) {
: TEST READABLE
: IF !READABLE
: CHANGE MODE TO READABLE OR DIE WITH ERROR MESSAGE
: }
:
: What I get as output is 'File is not readable and permissions can't be
: changed'.

Murphy is telling me the problem is somewhere in those paraphrased lines.
It's impossible to diagnose boguscode accurately.

You've probably made a mistake using the return from readdir()--a mistake
so common that half of the documentation for readdir() is there to ensure
you don't make it.

[...]
If you're planning to filetest the return values out of a
"readdir", you'd better prepend the directory in question.
Otherwise, because we didn't "chdir" there, it would have
been testing the wrong file.
 
D

David Jackson

You should read the documentation for the functions that you use.

Tad --

There's only been one "perfect" person I know of and we "nailed him to
a cross"....

Jeff --
You might for check/post http://perlmonks.com, maybe they'll remember
a time when they didn't not readying every man page for every function
for every program they wrote.

Sorry I cann't be of more help.

DJJ
 
M

Matt Garrish

Jeff said:
opendir(OUTDOOR, "${autodir}") || die "Can't open the dir ${autodir}";
@files = readdir(OUTDOOR);
closedir(OUTDOOR);
foreach $file (@files) {
TEST READABLE
IF !READABLE
CHANGE MODE TO READABLE OR DIE WITH ERROR MESSAGE
}

It would help if you hadn't left out the most important part of the code. My
guess is that you're either trying to change the permissions on '.' and
'..', or your running the script in a different directory from the files and
not prepending the full path. But unless you'd care to share the rest of
your code, there's not much anyone can do for you.

Matt
 
T

Tad McClellan

David Jackson said:
^^^^^^^^^^^^
^^^^^^^^^^^^

You might for check/post http://perlmonks.com, maybe they'll remember
a time when they didn't not readying every man page for every function
for every program they wrote.


We don't expect that here either. You're making shit up.

Sorry I cann't be of more help.


If he reads the documentation for the function that he is using
then he will have the solution to his problem.

I helped him, you did not help him.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top