don't understand working script



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

Relevant Pages

  • Re: local and my in subroutines
    ... I have a subroutine in the script below, printsub that errors when it is ... The second sub in this script works using: ... # Create extenions for log files as the older ones have a bz2 extension. ... foreach my $end ...
    (perl.beginners)
  • Re: Detecting is hyperthreading is enabled with WMI?
    ... It is too bad that WMI does not give this info. ... have to be done to the script. ... Public Sub DisplayProcessorInfo ... dim ProcessorSet, Processor ...
    (microsoft.public.windowsxp.wmi)
  • Cant make this page work
    ... I can't make this script work properly. ... The script at the bottom of the html page ... Does someone have a perl ... sub output_trace_headers { ...
    (comp.lang.javascript)
  • Re: Maybe I should try a different approach
    ... entire time my script is running, then have it close when my script is done and maybe have some dots keep adding to the text message until the script is fully completed? ... ' The "Three Ugly Hack" Script, ... Sub oATO_vbTimerEvent' timer event handler... ... Public Property Let Left ...
    (microsoft.public.scripting.vbscript)
  • Re: Win32_Product doesnt list all installed Applications
    ... 'Must have ADSI and WMI installed on PC running script. ... CONST ForReading = 1 ... Sub Connect ... strHTML = "Smoke'm if you Got'em" ...
    (microsoft.public.windows.server.scripting)