Public Function myfn(arg As Double) As Double myfn = arg + Rnd() End Function #### #!perl use 5.012; # strict, // use warnings; use Win32::OLE; my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); print "output = ", $Excel->Run('myfn', 17), "\n"; #### output = 17.468005657196