Path: utzoo!attcan!uunet!timbuk!cs.umn.edu!msi.umn.edu!src.honeywell.com!sol.ctr.columbia.edu!caen!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Recursion problem Message-ID: <10251@jpl-devvax.JPL.NASA.GOV> Date: 6 Nov 90 01:42:48 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 31 In article brister@decwrl.dec.com (James Brister) writes: : I'm writing a perl replacement for the lndir program that comes with X11. : The code (which follows) does a recursive walk of the directory tree and : seems to have two problems: : : 1) When the subroutine lndir hits the first leaf directory, the $file : variable in the foreach loop doesn't get incremented and an infinite : loops results. You didn't localize @dirlist, but $dirlist, which is otherwise not used. : 2) Does readdir reuire that an NFS file system be mount read-write? When I : try this program with a read-only file system directory as the first : argument, I only get the lost+found directory displayed in the "mkdir" : line. Shouldn't matter. Directories are effectively read-only all the time anyway. Larry P.S. Why the quotes around "DIR"? : opendir ("DIR",$source) || die "Can't opendir $source" ; : @dirlist = readdir ("DIR") ; : closedir ("DIR") ; opendir (DIR,$source) || die "Can't opendir $source" ; @dirlist = readdir (DIR) ; closedir (DIR) ; will work just fine.