Nesh has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks I am trying to convert the below VbScript to Perl Script. Can you please help with the following code
' Returns the exitCode of the report creation step Dim objErrorFSO, objLogFile Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 sub ProcessReport(prcsType) 'To call different process RUN COMPILE LOAD COPY APPEND depending upo +n the parameter passed. Set objErrorFSO = CreateObject("Scripting.FileSystemObject") If ((prcsType = "LOAD") OR (prcsType = "RUN")) and Trim(strPasswor +d) = "" Then Set WshShell = WScript.CreateObject("WScript.Shell") Set WshSysEnv = WshShell.Environment("SYSTEM") 'Open ActuateServerConnection.ini file wscript.echo(WshSysEnv("AC_CONNECTION_DETAILS")) If objErrorFSO.FileExists(WshSysEnv("AC_CONNECTION_DETAIL +S") & "ActuateServerConnection.ini") Then Set objTextFile = objErrorFSO.OpenTextFile(WshSysEn +v("AC_CONNECTION_DETAILS") & "ActuateServerConnection.ini",ForReading +) Else Call LogMessage("ActuateServerConnection.ini is not + Found") LogMessage("Load Return Code : 1") LogMessage("Quiting the script") LogMessage("Batch file return Code = 1") objLogFile.Close Call CreateLogFile(processType) WScript.Quit(255) End if
Thanks for your help.

Replies are listed 'Best First'.
Re: VBScript to Perl Script
by ww (Archbishop) on Mar 08, 2005 at 20:17 UTC
    uh, you want a Monastarian to translate that {)!(*)@# to perl?

    Many here will be pleased to help you learn... or even to get past one of those pre-d'oh moments when you just can't quite think of something you know perfectly well (except this minute)

    But a bald-faced "please work for me, for free" with no indication that you've made any effort to solve the problem is not a really welcome request here.

    Please read: How (Not) To Ask A Question.

Re: VBScript to Perl Script
by dragonchild (Archbishop) on Mar 08, 2005 at 20:05 UTC
    Why? If the script works in VB, then leave it in VB. If it ain't broke, don't fix it.

    Furthermore, you're doing a number of Win32-specific actions. This means that you will be bound to the Win32 set of modules. Which, frankly, are reimplementations of the VB API. For Windows-specific programming, I would stick with VB or C#.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: VBScript to Perl Script
by Errto (Vicar) on Mar 09, 2005 at 05:03 UTC
    Since I know some VBScript, I have a rough sense of what your program is doing, so I will give you some pointers to places in the Perl documentation that can help you:
    • Since you are looking at environment variables, check out %ENV in perlvar
    • for opening and writing to text files, look at perlopentut, open and print
    • for creating subroutines, such as "LogMessage" and "CreateLogFile", look at perlsub
    • if you really want to use objects such as WScript.Shell and Scripting.FileSystemObject in your Perl code (though you shouldn't), take a look at Win32::OLE
Re: VBScript to Perl Script
by PodMaster (Abbot) on Mar 09, 2005 at 05:10 UTC
    I don't know what "Perl Script" is, but PerlScript is an ActiveState product. You can read more about it here.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.