in reply to chomp - reference
Sidenote: Using both $array and @array in your code decreases its readability and makes it error prone.