I have a strange Perl problem I don't understand. I've written the
following program to scan different disks on a Windows server to look
for directory files. Works fine until it gets to 'e:' when I get this
warning:
Can't stat e:: Unknown file or directory
(If I don't have the "use warnings" in the code I get no message.)
There are folders and files on e:. I don't understand what the
problem is but I suspect there's some kind of syntax issue.
use File::Find;
use warnings;
@disks = ('h:','g:','f:','e:','d:');
$rfile = "sharebug.txt";
open (OFILE, ">$rfile") || die "Can't Open $rfile: $!\n";
foreach $disk (@disks)
{
printf ">>>Search disk: %s\n", $disk;
printf OFILE ">>>Search disk: %s\n", $disk;
@dir = ($disk);
find (\&wanted, @dir);
$dir = ();
}
close (OFILE);
exit;
sub wanted
{
use warnings;
$fname = $_;
if (-d $fname)
{
printf OFILE "$File::Find::name\n";
}
}
** Due to SPAM I no longer receive email responses to
** newsgroup postings, so don't bother. 2 6239
In article <pt********************************@4ax.com>, Abe
<ma*******@PLEASE.NOSPAM.gags-r-us.org> wrote: I have a strange Perl problem I don't understand. I've written the following program to scan different disks on a Windows server to look for directory files. Works fine until it gets to 'e:' when I get this warning:
Can't stat e:: Unknown file or directory
(If I don't have the "use warnings" in the code I get no message.)
There are folders and files on e:. I don't understand what the problem is but I suspect there's some kind of syntax issue.
If it were a syntax issue, perl would tell you about it. It is more
likely a permissions issue. I don't have a Windows server to test your
program, however. It looks like your syntax is fine.
I can make some suggestions:
use strict;
use File::Find; use warnings;
@disks = ('h:','g:','f:','e:','d:');
my @disks = ... # for this and all other variables $rfile = "sharebug.txt"; open (OFILE, ">$rfile") || die "Can't Open $rfile: $!\n";
foreach $disk (@disks)
foreach my $disk ( @disks )
{ printf ">>>Search disk: %s\n", $disk; printf OFILE ">>>Search disk: %s\n", $disk; @dir = ($disk);
You don't need to define an array to pass to find(). Perl will form an
array from all of your parameters and pass it to the subroutine.
Therefore, 'find ( \&wanted, $disk );' works fine.
find (\&wanted, @dir); $dir = ();
You don't need this in any case. There is no relation between $dir and
@dir (other than they live in the same glob).
} close (OFILE); exit;
sub wanted { use warnings;
There is no need to repeat 'use warnings' here.
$fname = $_; if (-d $fname) { printf OFILE "$File::Find::name\n"; } }
Last suggestion: post further questions to comp.lang.perl.misc. This
newsgroup is defunct.
Thanks. I just posted a slightly cleaned up version in the other
newsgroup.
I don't think it's a permission problem because if I change the
"@disk=" line to this:
@disks = ('h:','g:','f:','e:\\','d:');
It handles all the drives just fine.
On Tue, 23 Nov 2004 13:00:29 -0800, Jim Gibson
<jg*****@mail.arc.nasa.gov> wrote: In article <pt********************************@4ax.com>, Abe <ma*******@PLEASE.NOSPAM.gags-r-us.org> wrote:
I have a strange Perl problem I don't understand. I've written the following program to scan different disks on a Windows server to look for directory files. Works fine until it gets to 'e:' when I get this warning:
Can't stat e:: Unknown file or directory
(If I don't have the "use warnings" in the code I get no message.)
There are folders and files on e:. I don't understand what the problem is but I suspect there's some kind of syntax issue.
If it were a syntax issue, perl would tell you about it. It is more likely a permissions issue. I don't have a Windows server to test your program, however. It looks like your syntax is fine.
I can make some suggestions:
use strict;
use File::Find; use warnings;
@disks = ('h:','g:','f:','e:','d:');
my @disks = ... # for this and all other variables
$rfile = "sharebug.txt"; open (OFILE, ">$rfile") || die "Can't Open $rfile: $!\n";
foreach $disk (@disks)
foreach my $disk ( @disks )
{ printf ">>>Search disk: %s\n", $disk; printf OFILE ">>>Search disk: %s\n", $disk; @dir = ($disk);
You don't need to define an array to pass to find(). Perl will form an array from all of your parameters and pass it to the subroutine. Therefore, 'find ( \&wanted, $disk );' works fine.
find (\&wanted, @dir); $dir = ();
You don't need this in any case. There is no relation between $dir and @dir (other than they live in the same glob).
} close (OFILE); exit;
sub wanted { use warnings;
There is no need to repeat 'use warnings' here.
$fname = $_; if (-d $fname) { printf OFILE "$File::Find::name\n"; } }
Last suggestion: post further questions to comp.lang.perl.misc. This newsgroup is defunct.
** Due to SPAM I no longer receive email responses to
** newsgroup postings, so don't bother. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Richard Hanson |
last post by:
Over the last few days, I reinstalled Win2kSP2 to a spare harddrive I
had just swapped into my Fujitsu LifeBook P1120 (long story <wink>).
Subsequently, I DL'ed the newest Python alpha (2.4a2), and...
|
by: |
last post by:
Hello,
I tried to build Python 2.4.1 on a Reliant Unix system. Just after the
python executable program has been built, I get the following error:
==== begin make output ===
CC -W1...
|
by: David Farning |
last post by:
I am new to c and not yet sure of the boundary between c and it's
implementations. So please redirect me if this should be asked elsewhere.
I am working on a function to determine if a directory...
|
by: electric sheep |
last post by:
I'm not sure if this is POSIX or not ... and indeed if POSIX
is OT here or not, but if the subject made sense to you ....
I have a very simple program here, but it seems to be returning
a "true"...
|
by: David Bear |
last post by:
I'm trying to use os.chmod and am refered to the stat module.
Is there are explanation of:
* S_ISUID
* S_ISGID
* S_ENFMT
* S_ISVTX
* S_IREAD
* S_IWRITE
* S_IEXEC
| |
by: Theo Kanter |
last post by:
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 22
Message-ID: <Ca52h.21400$E02.8869@newsb.telia.net>
Date: Wed, 01 Nov 2006 17:53:38 GMT...
|
by: Joe Salmeri |
last post by:
I just upgraded from Python 2.4.2 to Python 2.5.1 and have found some
unexpected behavior that appears to be a bug in the os.stat module.
My OS is Windows XP SP2 + all updates.
I have several...
|
by: georgewa |
last post by:
Greetings all, great forum, this is my first post.
Recently trying to write a script that is designed to move files based on timestamps. I am fairly new to Perl, so please bare with me. I have...
|
by: perlvasu |
last post by:
6 jobs are running at the same time and accessing same dbm file for writing and reading. These are daily jobs and failing only some times not regularly. So i thought of this is just because of dead...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |