Search code examples
perlsyntax

What's the point of the header in Perl?


I was reading a tutorial that said every Perl programs should begin with a

#!D:\Perl\bin\perl

What is the purpose of that? It didn't explain at all on the tutorial.


Solution

  • There is no point to that "header". The shebang line is used by unix program loaders, which you're obviously not using.

    Without it, the system would have no way of knowing how to run your script. The person executing your script would have to launch perl and tell it to run the script themselves. In other words, it allows one to replace

    /usr/bin/perl program
    

    with

    program
    

    In Windows, this is handled by file associations.