Help for this page
my @paths_to_images = ("/webpics/originals/", "/webpics/itemthumb/", "/webpics/itemmed/");
foreach my $dir (@paths_to_images) { # Call the code you have for one directory now }