hi below i have a fully working script (on windows but you probably get the idea) the script looks in 2.854 directories 44.257 in files (its a very large website) to find certain lines and then write these lines along with information regarding the line number/the file name and path to a txt-file the only problem is the time it take to finish (about half an hour) so if anyone can point me in a direction where the script might be optimized iŽd musch appriciate it and as a sitenote - how can i correctly time the execution of this script. the included timing ($ialt)at the end are way off? thanks allan ______________ #! perl -w chdir("i:"); #change to relevant drive $start = (times)[0]; $startroot = "txtfiles"; $web = "some.txt"; $extensions = "asp"; #asp-files $txt_folder = "$startroot"; #start root &check_folders($txt_folder); #call sub foreach $file (@filelist) { #loop through all possible files if ($file =~ /(.+\\)(\w+\.($extensions))$/ig) { $splitme = $2 #get filename open(SPLIT, $file) or die "can not open $file"; #open file for reading @innersplit = <SPLIT>; for ($i=0; $i<=$#innersplit; $i++){ $count = $i +1; $searchline = $innersplit[$i]; if ($searchline =~ /select[^\w<>]+(?!.+\border\b\s+\bby\b)/ig) { push(@txtarray, "in the file $splitme at line numer $count\nthe full path is: $file\nthe line says $searchline\n"); } } } } open(SHOWER, ">$web") or die "cant write"; #collect all text in textfile print SHOWER @txtarray close(SHOWER); sub check_folders { #sub my($dir) = @_; local (*FOLDER); my(@subfiles, $file, $specfile); opendir(FOLDER, $dir) or die "cannot open $dir"; #open any directory @subfiles = readdir(FOLDER); closedir(FOLDER); foreach $file (@subfiles) { #loop through all files in any direcory $specfile = $dir . "\\" . $file; if (-d $specfile && $file !~ /^\.{1,2}$/) { &check_folders($specfile); #recursion } if ((-f $specfile) && ($file =~ /\w+\.$extensions$/ig)) { push(@filelist, $specfile); #get file in array } } } $end = (times)[0]; $ialt = $end - $start; print $ialt; ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org