Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!uunet!mcsun!cernvax!chx400!chx400!olsen!nagler From: nagler@olsen.UUCP (Rob Nagler) Newsgroups: comp.lang.perl Subject: Re: MS Perl Questions Summary: Yet another DOS workaround Message-ID: <220@munz.UUCP> Date: 7 Mar 91 19:06:46 GMT References: <1991Mar1.041441.4810@ccu1.aukuni.ac.nz> <1991Mar4.165742.12909@holos0.uucp> <4657@eastapps.East.Sun.COM> Reply-To: nagler@olsen.ch (Rob Nagler) Organization: Olsen & Associates, Zurich, Switzerland Lines: 55 Len Read writes: >>@REM=(" >>@perl 0%.bat ... >>@end=") > This often won't work, and it didn't really work in patch level 18 > when d.d.s. suggested doing it.... > I could not find a general solution to this problem. The following works ok with pl18 and pl44. Keep your industrial strength barf bags handy. Create a file (in your path) called _#perl.bat which contains: @perl %1 %2 %3 %4 %5 %6 %7 The top of your perl file should have. @_#perl -S %0.bat %1 %2 %3 %4 %5 %6 %7 ; This works because batch files under DOS do not nest, they chain. You could do something fancier, e.g. rename perl.exe to _#perl.exe and have an empty batch file called _#exit (or whatever) and have @_#perl -S %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9 ;@_#exit ; at the top, but this seems a lot more work for the benefit of 2 extra args. One minor problem with DOS perl, it doesn't automatically seach the current directory with the -S option. You can either put "." in your path. Of course, don't put any batch files in "\", because it won't find 'em; "." doesn't exist in the root directory. Tom Dinger writes: > If you are using a DOS version before 3.30, you have some problems, as the > '@' character is not recognised as suppressing echo of the command The above scheme will work for earlier DOS, but you'll have to name the _#perl.bat to be @_#perl.bat. > Limitations of the above: > 1. This will only work if you type the batch file name without an extension: > If you enter the command "t.bat" to DOS, perl will look for "t.bat.BAT" Technically, @_#perl.bat or _#perl.bat could really be a perl program that seaches for your perl file and then calls "do". However, there may be problems with DOS perl expanding args before you are ready, i.e. you can't call "exec" because the line is greater than 128 characters after the expansion. You could write a non-perl program that would do this work with the expansion problems. In practice, "can't execute foo.bat" doesn't occur very often and I don't pass very many "words" to my perl scripts anyway. Stick with the above. Flames to Bill Gates. Rob nagler@olsen.ch