in reply to Re^2: .pl or shebang (.bat)
in thread .pl or shebang
I use pl2bat too. Can't say I like it though. :) I use it for the reason mentioned by tye and because I need pipelines and file redirection to work, and last time I looked these two were badly broken by file associations, as documented at Perl 5.8.9 pl2bat doco (see the "ADVANTAGES" section).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: .pl or shebang (.bat)
by tye (Sage) on May 17, 2009 at 06:15 UTC | |
I've seen I/O redirection broken by file associations on some systems, but not recently. I've never seen an answer as to why it is broken on some systems (but seems to work on most systems -- no obvious differences found between systems where it works vs where it doesn't). Though, it was badly broken on all systems for some early version of WindowNT (as I recall). So you can probably stop using pl2bat, unless you have one of the rare systems that strangely still exhibit this problem. I've put pl2bat to some good uses (CleanPath, editd, SSH Agency, vienv - Edit local environment variables on Win32, etc.), uses that wouldn't work with a *.pl file. I never claimed that everybody would find jumping through the pl2bat hoop less painful than jumping though the PATHEXT hoop. There is already boilerplate that I include when I start a new Perl script so the extra boilerplate from pl2bat doesn't really add anything to the amount of work required to write a new Perl script (perhaps some people are just doing it wrong). I have a lot of experience with writing Perl scripts that I want to use on lots of different (Windows) computer systems or that other people want to use on other computers. So jumping through the PATHEXT hoop over and over and over again gets old pretty fast. And using pl2bat meant that it was trivial to detect that perl.exe wasn't in the path and then to mount my network share that has Perl on it and distribute a Perl script as a *.bat file that would work on any computer in our intranet. Running pl2bat couldn't be simpler (no options to specify, just enter the filename via tab completion), but I rarely run it anyway, at least not by hand. Most of my Perl scripts are either single-copy scripts that I just keep on my primary system as *.bat files or are in a source code repository and so there are scripts that know how to "install" them (steps such as some subset of: copy them to a directory in my $ENV{PATH}, "chmod +x" them, set the path to Perl on the #! line to work on the current system, run pl2bat, etc.). The only thing about pl2bat that bothers me, is that sometimes I initially forget to use "call" when dealing with *.bat files calling other *.bat files. - tye | [reply] |
|
Re^4: .pl or shebang (.bat)
by BrowserUk (Patriarch) on May 17, 2009 at 06:42 UTC | |
I need pipelines and file redirection to work, and last time I looked these two were badly broken by file associations, Hm. For as long as I've been using perl--7 years, 5.6.1 & NT4 sp1--input & output redirection and output pipelining have all worked fine using file associations:
The only (minor) inconvenience is for input piping you need to prefix the script name with 'perl':
But that's more than compensated for by not having to deal with the .bat nanny prompt:
And far outweighed by not having to remember to re-pl2bat if you edit the thing. But most of all, being able to add perl switches to the command line:
And finally, use perl's built-in switch parsing:
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |