Date: Sun, 04 Mar 2001 18:18:24 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: Daniel Barker Message-Id: <2110-Sun04Mar2001181824+0200-eliz@is.elta.co.il> X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6 CC: djgpp AT delorie DOT com In-reply-to: (message from Daniel Barker on Sun, 4 Mar 2001 14:58:15 +0000 (GMT)) Subject: Re: Penalty for immature language (PERL/BASH) References: Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > Newsgroups: comp.os.msdos.djgpp > Date: Sun, 4 Mar 2001 14:58:15 +0000 (GMT) > From: Daniel Barker > > I still have a small question. Neither BASH nor COMMAND.COM will run > poo.pl if I just enter the command poo (without extension). I expect > this. In BASH, I do not have . (current directory) in my PATH, and > COMMAND.COM does not regard .pl files as executable. So why is PERL even > trying to arrange execution of the file poo.pl? I don't know Perl well enough to answer that. My guess would be that Perl simply calls the library function `system' (or maybe `popen', which calls `system' internally) asking it to run `poo'. `system' looks and finds `poo.pl', but support for .pl scripts assumes that the first line of the script says what program should be invoked to run this script; `poo.pl' violates that assumption. I don't know what `poo.pl' was supposed to do, or how did you arrive at a program which ended up invoking it, but it sounds like a result of a rare coincidence together with a couple of subtle and hard-to-solve problems which have to do with running arbitrary programs on DOS/Windows. On balance, Perl should have been more cautious; it could, for example, check if the file is executable before invoking it. The next version of the DJGPP library changes the way `system' handles such files, because the current behavior is a bit unsafe, as you learned from this example. The modified `system' will not find `poo.pl' unless you actually mention the .pl extension. But I imagine even the new code will crash if you say `poo.pl` in a Perl program, and `poo.pl' doesn't have the "#!/usr/local/perl" on its first line.