A similar question about the use of
#! /usr/bin/perl
has been answered. But I think I have a slightly different question, although probably still similar to people in the know given my lack of understanding of computation in general.
I don't have UNIX on my Windows so could not test the following directly, but while the shebang line is indeed not needed for me to run Perl under Windows, with the shebang line in the hello.pl, I still could NOT run the file if I move from
c:\Users\XYZ\Desktop\BegPerl
to
c:\Users\XYZ\Desktop
My script is stored under
c:\Users\XYZ\Desktop\BegPerl
My perl folder is stored under
c:\Strawberry\perl\bin\perl.exe
So my questions are:
- How does Windows find "perl.exe"?
- Why could Windows find hello.pl ONLY when I type
perl hello.pl
underc:\Users\XYZ\Desktop\BegPerl
but NOT underc:\Users\XYZ\Desktop
even with the shebang line included?
The answer I got about the "purpose" of the shebang line is
for UNIX-like systems to locate the executable for scripts
So, I guess the answers to my two questions might have something to do with the difference between UNIX-like systems and Windows.