This is more of a general/aesthetics thing and isn't directly related to your question/resolution, but as you write your code and move on to other functions, the exact purpose of this variable may not be clear later. You may want to consider setting the variable to a name that makes sense as to the variable's function within the script so it is easier to debug if you have problems later. (unless $random makes enough sense to it's function). Personally, if I ever used the name random for a variable, it would be something that would only be used on a temporary basis. Not sure if this applies to you, but thought I'd put that out there.