my $dir = 'Startdir'; list_dir($dir); sub list_dir { my ($current) = @_; opendir my $dirh, $current or die $!; while( ... ) { # wie bei Dir im Programm # . und .. ausschließen if ( -d "$current/$entry" ) { list_dir( "$current/$entry" ); } } closedir $dirh; }