Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Gooday, i have written a short program that searches for a given directory. This works fine as long as i use a directory that i designed especially for this purpose(C:\Strawberry). If i change this:
$mp = "C:/Strawberry/";into this: $mp = "C:/";
my code no longer works. Does someone know why?
print "What folder?\n"; $term = <>; chomp $term; $mp = "C:/Strawberry/"; opendir($dh,$mp) || die "wtf??"; while( $tekst = readdir($dh)){ if(-d "$mp$tekst" && $tekst !~ /^\./){ if($term eq $tekst){ print "found: $mp$tekst\n"; } else{ $hulp ="$mp$tekst"; godeep($hulp); } } } close $dh; sub godeep{ $fld = shift; opendir($dir,$fld); while($tekst2= readdir($dir)){ if(-d "$fld/$tekst2" && $tekst2 !~/^\./) { if($term eq $tekst2){ print "found: $fld/$tekst2\n"; } else{ $hulp2 = "$fld/$tekst2"; godeep($hulp2); } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: search for folder
by Corion (Patriarch) on Dec 23, 2017 at 17:30 UTC | |
|
Re: search for folder
by atcroft (Abbot) on Dec 23, 2017 at 17:34 UTC | |
|
Re: search for folder
by 1nickt (Canon) on Dec 23, 2017 at 18:06 UTC | |
|
Re: search for folder
by thanos1983 (Parson) on Dec 23, 2017 at 22:23 UTC | |
|
Re: search for folder
by Anonymous Monk on Dec 24, 2017 at 08:07 UTC |