foreach (@nums){ push (@even, $_) if /\/2/; #match strings that contain '/2' push (@odd, $_) if /^\/2/; #match strings that start '/2' }