in reply to calling subroutines

five times generates a random number and passes it to the subroutine, printing the random number:
($a = int(rand(10)), sub{print shift,"\n"}->($a)) for 1..5;