This bit looks fishy:
foreach (@numbers) { unless ($_ == $1) { push @numbers,$1; } }
This would push $1 onto @numbers multiple times (once for each existing element that didn't match) except that it never runs at all since @numbers starts out empty. You could use the grep() function to check whether a value occurs in the array, but a better approach would be to use a hash instead and check with exists().
Also, your subroutine doesn't explicitly return a value.
In reply to Re: pondering array population
by grantm
in thread pondering array population
by elam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |