#!/usr/local/bin/perl
#directory.plx

my $top_directory=shift @ARGV;

my $count=0;
my $dir_handle=0;



opendirectory($top_directory);
print "$count\n";



sub opendirectory{

	my $directory=shift(@_);

	opendir "$dir_handle", '/etc/X11' or die "Can't find directory $directory: $!\n";

	while ($one =readdir("$dir_handle")){
		next if $one eq "." or $one eq "..";
		print "$one\n";
		
		if (-d $one){
			print "found a directory\n";
			++$count;
			opendir IN,"/etc/X11/$one" or die "Can't open directory $_: $!\n";
			while ($two=readdir(IN)){
					next if $two eq "." or $two eq "..";
					print "$one/$two\n";

					if (-d $two){
				
						print "found a directory\n";
						++$count;
						opendir IN1, $two or die "Can't open directory $_: $!\n";
						
						while ($three=readdir(IN1)){
					
							next if $three eq "." or $three eq "..";
							print "$one/$two/$three\n";
											
													
						
							if (-d $three){
								print "found a directory\n";
								++$count;
					
								opendir IN2, $three or die "Can't open directory $_: $!\n";
						
								while ($four=readdir(IN2)){
									
									next if $four eq "." or $four eq "..";
									print "$one/$two/$three/$four\n";
									}				
							
								
								}				
								closedir IN2;
							
							}	
							closedir IN1 ;
					}
	
				
			}
	
	closedir IN;
	}

}

closedir "$dir_handle";
}

