What you have written is
foreach (@nums){ push (@even, $_) if /\/2/; #match strings that contain '/2' push (@odd, $_) if /^\/2/; #match strings that start '/2' }
Try looking at the % (modulo) operator.
In reply to Re: Match all Odd and Even Numbers
by Bilbo
in thread Match all Odd and Even Numbers
by Dru
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |