I guess I´ll have to show you an example, this is is a Perl subroutine I´ve used to edit some filelevel permissions.

sub find_files						 
{
    if ($_ =~ /.[\/]$/){				
    	$_ = "$_[ 0 ]*";
      	} else {
    		  $_ = "$_[ 0 ]/*";
    		}
    
    my @directory,$i; 				
    @files = glob;           			      
    
    $i = 0;							 
       
    foreach $file (@files){			
       if (-d $file){				         
       $directory[$i] = $file;		      
         	$i++;        				 
 	    } else {						
			HERE_U_DO_STUFF_WITH_THE $file 								
    		    }
    }
    foreach $dir (@directory){
    	find_files($dir);
    }
}