Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

RE: Re: Still problems with recursive coding.

by jima (Vicar)
on Nov 13, 2000 at 20:32 UTC ( #41339=note: print w/ replies, xml ) Need Help??


in reply to Re: Still problems with recursive coding.
in thread Still problems with recursive coding.

Well, with respect to maintainability, I would think that File::Find would be much easier to maintain, once you understand how it works.

As for your code, the problem is the line

my @files = readdir(DIR) || die "Unable to read $workdir: $!\n";
The || operator has a higher precedence than the assignment, which means the readdir() gets evaluated in a scalar context; i.e., it returns only one directory entry. Try the or operator, for the effect you're looking for:
my @files = readdir(DIR) or die "Unable to read $workdir: $!\n";
(Now, if you had been using File::Find, you wouldn't have had to figure this out ;-) ...)


Comment on RE: Re: Still problems with recursive coding.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://41339]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2015-07-04 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls