in reply to Symbolic reference problem

opendir (D,'/home/www/'); while (defined(my $subdir = readdir D)) { open F, '/home/www/'.$subdir.'/logs/weekly' || do {warn "Couldnt open home/www/$subdir/logs/weekly: $!"; next}; while (<F>) { #your code } }
hope this helps
Update:

UPS... As pointed out below, I forgot to close my filehandles :(

T I M T O W T D I

Replies are listed 'Best First'.
Re: Re: Symbolic reference problem
by dragonchild (Archbishop) on Aug 20, 2001 at 16:42 UTC
    You forgot to both close your filehandles and your dirhandle. Rewritten, this should look like:
    opendir LOG_DIR, '/home/www/' or die "Cannot opendir /home/www"; while (defined(my $subdir = readdir LOG_DIR)) { open IN_FILE, '/home/www/'.$subdir.'/logs/weekly' || do {warn "Couldnt open home/www/$subdir/logs/weekly: $!"; next}; while (<IN_FILE>) { #your code } close IN_FILE; } closedir LOG_DIR;
    Yes, I know that Perl will implicitly close stuff for you, and that's fine for one-offs. BUT ... if this is going to run more than once or possibly be looked at by someone else, do things explicitly! And, it doesn't matter that something is 0.01 CPU seconds slower. CPU is cheap! Human-time is much more expensive, usually by a factor of 10,000 or more.

    ------
    /me wants to be the brightest bulb in the chandelier!

    Vote paco for President!