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/",
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
call it where my comment is.
For more complete directory recursion, use something like
File::Find or roll your own using opendir/readdir/closedir.