use strict; use warnings; sub search_dir { my ($dir) = @_; my $dh; if ( !opendir ($dh, $dir)) { warn "Unable to open $dir: $!\n"; return; } # Two dummy reads for . & .. readdir ($dh); readdir ($dh); while (my $file = readdir ($dh) ) { my $path = "$dir/$file"; # / should work on UNIX & Win32 if ( -d $path ) { print "Directory $path found\n"; search_dir ($path); } else { print "File $path found\n"; } } closedir ($dh); } ########################################################## print "Enter The Directory Path"; my $dir = ; chomp($dir); search_dir ($dir);