http://www.perlmonks.org?node_id=405781


in reply to help with search script

If you know all the directories, as your code seems to indicate, a simple way would be to define them as an array like this:

my @paths_to_images = ("/webpics/originals/", "/webpics/itemthumb/", "/webpics/itemmed/");
Then loop over them like this:
foreach my $dir (@paths_to_images) { # Call the code you have for one directory now }
You could either take the code you have an put it into the for loop block, or make what you have a sub and call it where my comment is.

For more complete directory recursion, use something like File::Find or roll your own using opendir/readdir/closedir.