On Friday, April 26, 2002, at 07:21 PM, Michael Turner wrote:

> Note the missing "she-bang" line: #!/usr/bin/perl -w   Note also that I 
> didn't tell the shell "how" to execute the file. So the file is set to 
> executable, but I thought it should error. Is that line not necessary 
> on a Mac for some reason? How is this a Mac thing? It is not functional 
> on other unix  machines I have access to (and I tried various shells, 
> including tcsh & bash). I repeated the experiment with no ".pl" 
> extension, that isn't it.

I repeated your experiment, but with a .sh extension instead. It worked. 
Then, I ran the script with "sh test.sh" - again, it worked.

Then, I tried another script:

print $ENV{'HOME'};

The output was this:

{HOME}

Aha! That's the output that one would expect if $ENV{'HOME'} were 
evaluated in a shell script, rather than a Perl script.

It appears that the shell, when asked to run something that isn't a 
binary and has no shebang, defaults to running it as a shell script. As 
it happens, the output of your first test script is the same, regardless 
of whether it's run by the shell or by Perl.

sherm--

Never put off until tomorrow what you can do today. There might be a law 
against it by that time.

Reply via email to