... open my $fh, '<', 'numbs.dat' or die $!; my $pick = genPicker( $fh ); ## Reads the file and generates a picker subroutine according to its contents. close $fh; ### use $pick->() each time you want a new random number.