-# Otherwise walk $plugin_dir to get list of plugins to use
-elsif ( $plugin_dir and opendir PLUGINS, $plugin_dir ) {
- @plugin_list = grep { /^[\w:]+$/ && ! /~$/ && -f "$plugin_dir/$_" } sort readdir(PLUGINS);
- closedir PLUGINS;
+# Otherwise walk @plugin_dirs to get list of plugins to use
+elsif ( @plugin_dirs ) {
+ for my $plugin_dir ( @plugin_dirs ) {
+ next unless -d $plugin_dir;
+ if ( opendir PLUGINS, $plugin_dir ) {
+ for my $plugin ( grep { /^[\w:]+$/ && ! /~$/ && -f "$plugin_dir/$_" } readdir(PLUGINS) ) {
+ # Ignore duplicates
+ next if $plugin_hash{ $plugin };
+ # Add to @plugin_list and %plugin_hash
+ $plugin_hash{ $plugin } = "$plugin_dir/$plugin";
+ push @plugin_list, $plugin;
+ }
+ closedir PLUGINS;
+ }
+ }
+ @plugin_list = sort @plugin_list;