Can someone explain to me what this script really does? I mean I see that it
lists dir within dir. But what is the code doing? For example all the blue
highlighted stuff, what is it doing?
#!/usr/bin/perl
$startdir = "/lib";
$level = 0;
list_dirs($startdir,$level);
sub list_dirs(){
my $dir = shift (@_);
my $lev = shift (@_);
opendir(TOP,$dir);
my @files = readdir(TOP);
closedir(TOP);
shift(@files);
shift(@files);
foreach $file (@files){
if(-d "$dir/$file"){
spaces($lev);
print "$file\n";
list_dirs("$dir/$file",$lev+1);
}
}
}
sub spaces(){
my($num) = shift(@_);
for($i=0;$i<$num;$i++){
print " ";
}
}