Why there is #! perl at the top of .t files?

I noticed that at the top of the perl test there #!perlis .t, as far as I know, you cannot execute it like ./test.tthat because it will require them to be executed and use the full track. So why do these files usually have this?

+3
source share
2 answers
  • To tell editors about the syntax, highlight the file as Perl code.
  • If you want to provide a set of default options for perlwhen you run this file. (See perlrun .)

(On the side, on Unix systems, the extension does not matter. If the execution bit is set in the file, the OS will consider the file as a program, so you can run it. When you try to do this, the OS will look at the first line to determine which call the command (and arguments) using the program, however, it doesn’t matter here, since the OS does not search $PATHfor non-absolute paths - it will only search in relation to your current directory, therefore #!perlit will not work. You need an absolute path in practice .)

+9
source

, , , , perl, , " ", Perl . file , . , Perl, , , Macintosh, . , , , . , , perl .t - . , , perl.

+2

Source: https://habr.com/ru/post/1779755/


All Articles