VicBalta has asked for the wisdom of the Perl Monks concerning the following question:
Hi
Well when I first ran into this problem I thought that it would be a simple problem to solve. but I can't seem to figure it out. The problem occurs when I am using File::Find to recusivly search a direcotry for files. The problem is that when i get to a directory that doesn't exist it prints out.
Can't stat e:\logs: No such file or directoryI have to search many directories and if the program doesn't find one it just spits out this message and goes on to the next one. Well I want to be able to know if it couldn't not find that direcotry.
Well at first i tried setting a variable equal to tbe return value.
my $temp = find ({wanted => \&wanted,bydepth =>0},"e:\\logs",);But the problem was that even if it worked or if it didn't find the directory it would return zero. So next I tried to eval the statement and to catch the error that way.
But it didn't catch the errorI know that there is a module out there called "exceptions" to use try and catch but I installed it and it tells me i need to install "methodmaker". And I don't even know if exceptions will work. I know that there is also something that is called "backticks" that is used to get what is outputed to the screen (i think). Is there a simple way to figure out if it returned an error or not??any help would be great thanks,Victoreval{ find ({wanted => \&wanted,bydepth =>0},"e:\\logs",) }; warn $@ if $@;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: catching errors from file::find
by Fastolfe (Vicar) on Nov 09, 2001 at 01:51 UTC | |
|
(jeffa) Re: catching errors from file::find
by jeffa (Bishop) on Nov 09, 2001 at 02:01 UTC | |
|
Re: catching errors from file::find
by belg4mit (Prior) on Nov 09, 2001 at 01:52 UTC | |
|
Re: catching errors from file::find
by tachyon (Chancellor) on Nov 09, 2001 at 06:17 UTC | |
|
Re: catching errors from file::find
by gloryhack (Deacon) on Nov 10, 2001 at 00:03 UTC | |
|
Pathing under Windows
by petdance (Parson) on Nov 10, 2001 at 09:24 UTC | |
by gloryhack (Deacon) on Nov 10, 2001 at 12:12 UTC | |
by earthboundmisfit (Chaplain) on Nov 14, 2001 at 19:35 UTC |