my @a; my @b; GetOptions ( "a=s" => \@a, "b=s" => \@b ); @a = split(/,/,join(',',@a)); @b = split(/,/,join(',',@b)); if ( scalar(@a) !=2 || scalar(@b) !=2 ){ # shout at user here }