Unique elements in a perl array

    I want to have an array in perl with only unique elements. My current hacky way is to misuse a hash, is there a nicer way of doing this?

      # This function is similar to the above, but returns a list of the
      # directories containing at least one image.
      #
      # Pass in the path to the parent directory
      sub getdirectories{
          my($path) = @_;
          my(%directories);
      
          find(sub{
      	# Again, this needs to be tweaked if other image formats are
      	# to be supported
      	if($File::Find::name =~ /\/([^\/]*\.jpg)$/i){
      	    # This is a horrible, horrible hack
      	    $directories{$File::Find::dir} = "yes";
      	}
          }, $path);
      
          return keys %directories;
      }
      


    Technorati tags for this post:

posted at: 22:04 | path: /perl | permanent link to this entry