don't understand working script
- From: amichai@xxxxxxxxxx (Amichai Teumim)
- Date: Thu, 28 Jun 2007 13:17:51 +0300
I have this script, If you run it you can see how it nicely idents the
directories. I don't understand everything in this script. Please see my
comments.
#!/usr/bin/perl
$startdir = "/lib";
$level = 0; #WHAT DOES THIS DO?
list_dirs($startdir,$level); #WHAT DOES THIS DO?
sub list_dirs(){
my $dir = shift (@_); #WHAT DOES THIS DO?
my $lev = shift (@_); #WHAT DOES THIS DO?
opendir(TOP,$dir);
my @files = readdir(TOP);
closedir(TOP);
shift(@files);
shift(@files);
foreach $file (@files){
if(-d "$dir/$file"){
spaces($lev); #WHAT DOES THIS DO?
print "$file\n";
list_dirs("$dir/$file",$lev+1); #WHAT DOES THIS DO?
}
}
}
#WHAT DOES THIS WHOLE SECTION DO?
sub spaces(){
my($num) = shift(@_);
for($i=0;$i<$num;$i++){
print " ";
}
}
Thanks
Amichai
- Follow-Ups:
- Re: don't understand working script
- From: John W. Krahn
- Re: don't understand working script
- From: Chas Owens
- Re: don't understand working script
- Prev by Date: parsing a line
- Next by Date: Re: String Manipulation
- Previous by thread: parsing a line
- Next by thread: Re: don't understand working script
- Index(es):
Relevant Pages
|