Perl Script within a DOS Batch with delayed exit

Perl script and batch in a single file.

Description:

This example works just as the previews one but will wait 4 seconds before the application finally closes. This is just enough time to inspect the screen output before the window vanishes. The delay can probably be done much easier in Perl, but somebody just starting on Perl might find this still useful.

Script: Download: Batch4Perl2.bat  
1.
2.
3.
4.
5.
6.
7.
8.
9.
@rem = 'Perl, ccperl will read this as an array of assignment & skip this block
@CD /d "%~dp0"
@perl -s "%~nx0" %*
@FOR /L %%c in (4,-1,1) do @(TITLE %~nx0 - %%cs to close & ping -n 2 -w 1000 127.0.0.1 >NUL)
@TITLE Press any key to close the window&ECHO.&GOTO:EOF
@rem ';

#perl script starts below here
print 'Hi there!  DOS rocks!\n'