in reply to Thumbnail autoindex

#look for files in $DIR sub collect_files { opendir(DIR, "$DIR"); while (defined(my $file = readdir(DIR))) { if ( ! -d $file ) { &check_mime_type($file); } } closedir(DIR); } #collect files, create thumbnails and pass list of images back to cgi +output sub collect_thumbs { &collect_files; my @thumbs; opendir(DIR, "$DIR/thumbs"); while (defined(my $file = readdir(DIR))) { if ( ! -d $file ) { push(@thumbs, $file); } } closedir(DIR); return @thumbs; }

readdir gives you a file name from the directory $DIR (or "$DIR/thumbs") but you are not testing the file in that directory ( ! -d $file ), you are testing it in the current directory.   You need to prepend the directory name to the file name to test the correct file.

You should also always verify that open, opendir and unlink worked correctly.

See also: What's wrong with always quoting "$vars"?

Replies are listed 'Best First'.
Re^2: Thumbnail autoindex
by ScOut3R (Sexton) on Dec 06, 2008 at 21:46 UTC
    Thank you for your advice! It's obvious that i don't have enough experience yet. I'll add the suggested verification.