in reply to how to split hash into two arrays

I think you don't need any extra array. Just the sub you already have. If some param is not passed, null will be assigned to $array->[x]:
C:\>perl -le "use strict;use warnings;sub f{my($x,$y)=@_;my $aa=$x;my +$bb=$y; print $aa, ' ', $bb}; f(1); f(2,3)" Use of uninitialized value $bb in print at -e line 1. 1 2 3
This means, that in first case $bb equals 'undef' as you want.