Hi I have this code where I try to read a folder, and then exclude some files/folders. So far so good this part works fine. But then I want to take the rest of the files and check them if they are folders or files if they are folders then I need to read them as subfolders an re-read the for files and subsubfolders, if they are files I need to push them into the array filelist containing all the filenames in the directory and subdirectories. When I run this script I just get a OUT OF MEMORY. Where am I looping it? I feel Like I'm spamming all of you with a lot of questions. I will return soon with a summery of all of yours replies on my earlier question about : Putting hash values in an array and checking that with an foreach is not working ..... Thanks a lot for all your help with Ideas and pointers. I'm still just in the beginning phase of my "perl"ing. (A.K.A Major Newbie) Yours sincerely Jimmy Lantz Sweden #!perl ######### #Macperl! ######## $infolder = 'Server G4:DATABAS:'; # Exclude the following files/folders. @exfiles = ('data'); ##################### opendir(DIR, "$infolder") or die "cannot open $infolder"; @files = readdir(DIR); closedir(DIR); &do_exclude; foreach $file (@files) { &do_readdir("$file"); } print @filelist; exit; ########################### sub do_readdir { my($specfile) = @_ ; if ($specfile !~ m/$infolder/) #otherwise add the maindir { my($adress) = $infolder . $specfile; } else { my($adress) = $specfile; } if (-d "$adress") { &do_readsubdir("$adress"); } else { push(@filelist, "$adress"); } } ###################### sub do_readsubdir { my($specfolder) = @_ ; opendir(DIR, "$specfolder") or die "cannot open $specfolder"; my(@subfiles) = readdir(DIR); closedir(DIR); foreach $subfile (@subfiles) { &do_readdir("$subfile"); } } #################### sub do_exclude #This ones works fine from perlfaq4! { @union = @intersection = @difference = (); %count = (); foreach $element (@files, @exfiles) { $count{$element}++ } foreach $element (keys %count) { push @union, $element; push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element; } @files = @difference; # assign the difference to @files } ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org