Perl: random select

How do I:

  1. Have a list of names. JOE, JOHN, PETER, PAT.
    how do i get perl to randomly select any two and put them in $name1 and put the other two in $name2 ?

Possibly there are more efficient ways of doing it, but ...

@names = ('A', 'B', 'C', 'D');
$counter = 0;
while ($counter < 2) {
	my $subscript = rand(@names)+1;
	if (defined $names[$subscript]) {
		push @name1, $names[$subscript];
		$names[$subscript] = undef;
		$counter++;
	}
}

for (@names) {
	push @name2, $_ if defined;
}