http://www.perlmonks.org?node_id=140474

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

We package a version of perl with our commercial software product. (yes, yes boo on me for selling closed source; i don't like it either but one has to pay the bills.) Of course, there's no way to know in advance exactly where a client will install our software - as in what directory structure they will use. So I have to write scripts all the time that need to first find perl, and then run the main body of the code. Since I can depend on sh just about everywhere, for Unix I have a sh script which finds perl for me based on some ENV variables that our software always sets and the runs perl using the old  exec $PERL -x $0 $* trick, $PERL having been set by the sh portion of the code (I'll include full code below for the curious). What I need is a win32 batch script equivalent of this and I don't even know where to begin. Any win32 peeps out there think they can help? I hope this question is clear enough.... =]

We speak the way we breathe. --Fugazi

#!/bin/ksh # -*- perl -*- # these are the varibles you change ####################################### IGNORE_NO_USER=N # 'Y' or 'N' ####################################### # DONT CHANGE STUFF AFTER THIS ARCH=$(uname -s)$(uname -r) if [[ $ARCH = "SunOS5.5.1" ]]; then ARCH=SunOS5.5 elif [[ $(echo $ARCH|grep -c "HP-UXB.10") -gt 0 ]]; then ARCH=HP-UXB.10 elif [[ $(echo $ARCH|grep -c "HP-UXB.11") -gt 0 ]]; then ARCH=HP-UXB.11 elif [[ $(echo $ARCH|grep -c "Linux2.2") -gt 0 ]]; then ARCH=Linux2.2 fi BIN=$HOME/bin/$ARCH if [[ ! -d $BIN ]]; then echo "ERROR: \$BIN not found ($BIN)" exit 1 fi LD_LIBRARY_PATH=$HOME/lib/$ARCH if [[ $(echo $ARCH|grep -c "HP-UXB") -gt 0 ]]; then export SHLIB_PATH=$HOME/lib/$ARCH:$SHLIB_PATH fi PLAT=$(uname -s) PERL=$HOME/tools/bin/$PLAT/perl if [[ ! -x $PERL ]]; then echo "ERROR: \$PERL not found ($PERL)" exit 1 fi export HOME ARCH BIN PLAT LD_LIBRARY_PATH IGNORE_NO_USER exec $PERL -x $0 $* #--------------------------------------------------------------------- +---------- #!/bin/perl # # perl code starts after this