Hi all, thanks in advance for any help...
what I want to do is: 1) read in a file containing daily total hits to certain urls within a subdirectory so total.030922 would contain: month date subdir and total count for this date example: Sep 22 airport 4 Sep 22 alumni 5 2) read in the files in this subdirectory using readdir if the url matches the subdirs in total.030922 I write to a file: month date and count if it doesn't match I write to a file: month date 0 3) problem, how do I get it to write only once, rather than writing each time through the loop I've tried next and last, but no luck here's the code in question, and sample output below: sub get_output{ @subdirs = readdir(DIR); for $subdir(sort @subdirs){ next if $subdir eq "." or $subdir eq ".."; #lets clean this up $subdir =~ s/\.html//g; $subdir =~ s/README//g; $subdir =~ s/X//g; $subdir =~ s/count//g; $subdir =~ s/index//g; $subdir =~ s/dir.shtml//g; open(FILE, "/dept/unxmkt/bin/hits/welcome/logs/total.$fname") or die("no tally file: $!"); while($line = <FILE>){ ($month, $day, $url, $count) = split(/ /, $line); print("subdir= $subdir"); print("-- url = $url\n"); if ($subdir =~ /$url/){ open(OUT, ">>$outdir/$subdir.shtml") or die("No shtml $!"); print ("YES $month $day $count <br \>\n"); print OUT ("YES $month $day $count\n"); close OUT; next; } if ($subdir !~ /$file/){ open(OUT, ">>$outdir/$subdir.shtml") or die("No shtml $!"); print ("NO $month $day 0 <br />\n"); print OUT ("NO $month $day 0 \n"); close OUT; next; } } #end foreach } #end while sample output: subdir= airport-- url = airport YES Sep 22 3 <br > subdir= airpot-- url = alumni NO Sep 22 0 <br /> subdir= airport-- url = hr NO Sep 22 0 <br /> subdir= airport-- url = pm2 NO Sep 22 0 <br /> subdir= airport-- url = software NO Sep 22 0 <br /> subdir= alumni-- url = airport NO Sep 22 0 <br /> subdir= alumni-- url = alumni YES Sep 22 3 <br > subdir= alumni-- url = hr NO Sep 22 0 <br /> subdir= alumni-- url = pm2 NO Sep 22 0 <br /> subdir= alumni-- url = software NO Sep 22 0 <br /> subdir= caa-- url = airport NO Sep 22 0 <br /> subdir= caa-- url = alumni NO Sep 22 0 <br /> subdir= caa-- url = hr NO Sep 22 0 <br /> subdir= caa-- url = pm2 NO Sep 22 0 <br /> subdir= caa-- url = software NO Sep 22 0 <br /> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]