Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!husc6!genrad!decvax.dec.com!decvax!evans From: evans@decvax.dec.com (Marc Evans) Newsgroups: comp.lang.perl Subject: Re: Recursive Subroutines - Help sought Message-ID: <428@decvax.decvax.dec.com.UUCP> Date: 30 Oct 90 16:22:50 GMT References: <1990Oct29.140931.5498@chx400.switch.ch> Sender: news@decvax.dec.com.UUCP Reply-To: evans@decvax.DEC.COM Organization: Synergytics Lines: 35 In article <1990Oct29.140931.5498@chx400.switch.ch>, lengge@chx400.switch.ch (Thomas Lenggenhager) writes: |> Who can find the bug in my program, or who suggests a better solution to my |> problem. How about this instead: print "Directory: "; $dirname = ; chop($dirname); do read_dir($dirname); exit 0; sub read_dir { local($dirname)=@_; opendir(DIR,$dirname); local(@entries)=readdir(DIR); closedir(DIR); local($entry); while ( $entry=shift(@entries) ) { next if ($entry eq "." || $entry eq ".."); if (-d $entry) { do read_dir("$dirname/$entry"); print "$dirname/\n"; } else { print "$dirname/$filename\n"; } } } -- =========================================================================== Marc Evans - WB1GRH - evans@decvax.DEC.COM | Synergytics (603)635-8876 Unix and X Software Contractor | 21 Hinds Ln, Pelham, NH 03076 ===========================================================================