What is the difference between "perl test.pl" and "./test.pl"?

perl

Solution

In the first case you are starting the `perl` interpreter and asking it to use your file and run it.

In the second case you are asking your shell to execute your file. This requires that the file starts with

#!/<path to perl>/perl

and that the file has the execute bit set.

The best method to use is the one that fits your usecase the best.

Problem

I have observed that there are two ways of executing a perl program: ``` perl test.pl ``` and ``` ./test.pl ``` What is the exact difference between these two and which one is recommendable?

Original source

Related problems