2

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.

Jens
  • 69,818
  • 15
  • 125
  • 179
mtrmilk
  • 49
  • 1
  • 8
  • possible duplicate of [Why should the shebang line always be the first line?](http://stackoverflow.com/questions/12910744/why-should-the-shebang-line-always-be-the-first-line) – Quentin Mar 04 '13 at 14:03
  • 2
    The answers to that linked question aren't relevant to the OP, so it's definitely not a duplicate question. (It's useful extra reading, though) – ikegami Mar 04 '13 at 14:04

2 Answers2

9

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.

ikegami
  • 367,544
  • 15
  • 269
  • 518
5

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.

ikegami
  • 367,544
  • 15
  • 269
  • 518
Craig Treptow
  • 834
  • 7
  • 19