in reply to Hash not working as intended

If you're using this to generate filenames, why not check to see if the file exists?
do { $hash{$_}++ } until ! -f $_;
Update: Umm, there's a large probability I may have misunderstood what you're trying to accomplish.