You really, really need strictures - always use strictures (use strict; use warnings; - see The strictures, according to Seuss). A quick glance through your code shows the following issues, at least some of which would be highlighted by 'strict':
In reply to Re: Sorting array, getting modification of read-only value error
by GrandFather
in thread Sorting array, getting modification of read-only value error
by myelinviolin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |