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

Hi Folks, I am a novice in batch file programming and I am having a problem writing a batch file to install Perl modules. Here is the code
:: opt_ppm_patch.bat :: installs ppm packages @echo off echo Adding the current directory to Perl Package Manager (PPM) ppm rep add REPOS . :libxml_perl echo Installing libxml-perl package ppm query libxml-perl IF NOT "%OUT%" == "No matches" goto XML_REG ppm install libxml-perl.ppd :XML_REG ppm query XML-RegExp IF NOT "%OUT%" == "No matches" goto XML_DOM echo Installing XML-RegExp package ppm install XML-RegExp.ppd :XML_DOM ppm query XML-DOM IF NOT "%OUT%" == "No matches" goto END echo Installing XML-DOM package ppm install XML-DOM.ppd :END echo Deleting the repository entry from PPM ppm rep del REPOS echo Completed installing perl modules.
And here is the output of the above code
Adding the current directory to Perl Package Manager (PPM) Repositories: [1] REPOS [ ] my [ ] new [ ] path
The problem is the first ppm command is executed successfully and the batch file just exits out when done. Can any one please explain as to why is such a thing happening and any work around for this problem Thanks and Regards, Sid

Replies are listed 'Best First'.
Re: PPM problem, running ppm in batch file
by holli (Abbot) on Aug 31, 2006 at 11:34 UTC
    ppm is a batch file itself. if you call a batch file from another batch file the calling batchfile ends. If you don't want that behaviour you have to call the batch using the call keyword. Hence your code becomes
    :: opt_ppm_patch.bat :: installs ppm packages @echo off echo Adding the current directory to Perl Package Manager (PPM) call ppm rep add REPOS . :libxml_perl echo Installing libxml-perl package call ppm query libxml-perl IF NOT "%OUT%" == "No matches" goto XML_REG call ppm install libxml-perl.ppd :XML_REG call ppm query XML-RegExp IF NOT "%OUT%" == "No matches" goto XML_DOM echo Installing XML-RegExp package call ppm install XML-RegExp.ppd :XML_DOM call ppm query XML-DOM IF NOT "%OUT%" == "No matches" goto END echo Installing XML-DOM package call ppm install XML-DOM.ppd :END echo Deleting the repository entry from PPM call ppm rep del REPOS echo Completed installing perl modules.


    holli, /regexed monk/
Re: PPM problem, running ppm in batch file
by Burak (Chaplain) on Aug 31, 2006 at 17:51 UTC
    Why don't you just use Perl? i.e.: system(), exec() or bacticks or use()ing PPM modules directly? That code you wrote gives me the creeps :p