Contributed by bsb
on Jul 26, 2002 at 00:56 UTC
> programs and processes
Under Win NT using cmd.exe as the shell:
On the command line -F works fine
>perl -naF, -e "print @F" all_data.txt
>perl -naF/,/ -e "print @F" all_data.txt
>perl -naF',' -e "print @F" all_data.txt
>perl -naF"," -e "print @F" all_data.txt
But in a shebang line in a file I can't find a
way to have the switch processed:
#!/usr/bin/perl -na -F,
... not split, $F eq $_
With -F/,/ or -F"," or -F',' I get:
syntax error at E:\gust\script.pl line 2, near "print"
|Answer: Does #!perl -na -F/,/ work on Win NT?|
contributed by BrowserUk
Unfortunately, CMD.EXE does use the shebang line in your perl script. The Win32 mechanism for knowing which executable to use to process a given file is quite different. Being ASSOC and FTYPE; On my system these are set as follows:
perl_script=e:\perl\bin\perl.exe -w %1 %*
Use HELP ASSOC|FTYPE for fulll definition of these commmands.
You will notice that I have modifes the ftype line and added the -w before any passed args. You could modify this on your system to have the -naF switches, but this would then be used for all Perl scripts run on that system which isn't very useful.
The second and probably best alternative is to use the ActiveSystems (assuming your using AS) supplied pl2bat command on your script, and the edit the top of it to have the switches you want.
Example: (additions in bold):
perl -x -S "%0" -na -F %1 %2 %3 %4 %5 %6 %7 %8 %9
@rem = '--*-Perl-*--
if "%OS%" == "Windows_NT" goto WinNT
perl -x -S %0 -na -F %*
#YOUR CODE START HERE!!!
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
For further information for ActiveState installations read the AS docs at: A/S docs
(The above link assumes AS perl istalled in the default directories on your C: drive. Adjust as necessary on the addressline of your browser.
Edited bits per authors req. - dvergin 2002-07-29
Please (register and) log in if you wish to add an answer
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||