#!/usr/local/bin/perl4 -w # Recurse the file system and do something # (just print the file name in this case) # subroutine Searchfiles does all the work sub Searchfiles { local ($dir) = @_; local (@allfiles); opendir (DIR, "$dir") || die "problems: $dir $!"; @allfiles = readdir DIR; closedir DIR; $dir .= $sep unless $dir =~ /${sep}$/; foreach $filename (@allfiles) { if ((-d $dir.$filename)) { &Searchfiles ($dir.$filename) if ($filename !~ m/^\./); } else { # we could do something much more clever here, of course print $dir.$filename,"\n"; } } } # if you don't have a pwd do this # $top = $ARGV[0] || "win3_"; # and choose the correct separator # $sep = '_'; # with pwd, work out for ourselves :-) chop ($top = `pwd`) unless ($top = shift); ($sep) = $top =~ /(^\/|_$)/; &Searchfiles ($top); #start here.