sub find_and_remove () { # pulls the referenced array into the subroutine and saves it in variable $reference $reference = $_[0]; # selects a random number from array size. $random_number = int(rand(@col2c)); # saves that-numbered variable from the array as $nowvalue $nowvalue = @$reference[$random_number]; # removes the variable from the array so it can't be selected again splice (@$reference, $random_number, 1); # returns the selected value return $nowvalue; }