We can use the following vba code to execute perl,
Sub runPerl(fileName As String, Optional param1 As String, Optional param2 As String, Optional param3 As String)
'MsgBox "file name = " & fileName & ", param1 = " & param1 & ", param2 = " & param2
Dim oWsc As Object
Set oWsc = CreateObject("WScript.Shell")
Dim oExec As Object
Set oExec = oWsc.Exec("perl " & Chr(34) & ThisWorkbook.Path & "\" & fileName & Chr(34) & " " & param1 & " " & param2 & " " & param3)
While oExec.Status <> 1 ' Wait for process
' Sleeping phase
Wend
'MsgBox ("STDOUT" + oExec.StdOut.ReadAll())
'MsgBox ("STDERR" + oExec.StdErr.ReadAll())
Set oWsc = Nothing
'MsgBox ("End of macro")
End Sub
when filename is the name of perl file and param1, param2 , ... are the arguments of perl file that are optional
we can use the above function by calling it like this,
runPerl sayHi, alongkorn