in reply to Empty Elements

Where is the regular expression you expect to set $1? Did you mean $i or $_ instead? If you do mean $1, do you know the regex matched?

perlfaq4 has a nice implementation of the Fisher-Yates algorithm that will work for you.