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

I believe I can call a perl program from within a dos bat file, but I'd like to know if it is possible to return a value (ie: status - could be numeric or text) from the perl program back to the executing bat file. Win2k.
  • Comment on Return a value from Perl pgm called by a dos bat file

Replies are listed 'Best First'.
Re: Return a value from Perl pgm called by a dos bat file
by gellyfish (Monsignor) on Apr 29, 2004 at 16:39 UTC

    Yes, the value you return from your program with exit() will be available to the %ERRORLEVEL variable in your batch file

    /J\

Re: Return a value from Perl pgm called by a dos bat file
by NetWallah (Canon) on Apr 29, 2004 at 18:46 UTC
    Here is a sample BAT file that expands on what gellyfish said:
    perl -e "exit 5" echo %ERRORLEVEL%
    The code above prints "5" , which is what the %ERRORLEVEL% gets set to.

    Offense, like beauty, is in the eye of the beholder, and a fantasy.
    By guaranteeing freedom of expression, the First Amendment also guarntees offense.