'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 1:[1]

That line in scripts is the known as the shebang. In a unix type of operating system, it tells the program loader what the rest of the file should be processed with.

I think the norm now is to use a perl found on the path with a line such as:

#!/usr/bin/env perl

Since yours looks like Windows, the shebang is largely ignored, but perl does still look to it to see if you passed a flag such -w or -T for instance.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ikegami