Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Perl interpretation of weird #! line

by jesuashok (Curate)
on Jan 09, 2006 at 06:51 UTC ( #521861=perlquestion: print w/replies, xml ) Need Help??

jesuashok has asked for the wisdom of the Perl Monks concerning the following question:

Hi all Gr8 People,


I saw a above line in one of perl source code which is Very new to me since I am working in Perl only in Unix and linux.

what does that line mean ?
what does it day to perl interpreter ?
Is the above line specific to any Os dependant ?

Please provide me your Valuable points which will help me and others a lot.

"Keep pouring your ideas"

2006-01-09 Retitled by broquaint, as per Monastery guidelines
Original title: 'Perl Interpration'

2006-01-10 Edited by planetscape - fixed formatting/markup

Replies are listed 'Best First'.
Re: Perl interpretation of weird #! line
by davorg (Chancellor) on Jan 09, 2006 at 09:48 UTC

    I strongly suspect that is a template variable that will be expanded to a real Perl path as part of the process which puts the program into production.


    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: Perl interpretation of weird #! line
by rinceWind (Monsignor) on Jan 09, 2006 at 11:48 UTC

    As others have said, what you have is a shebang line for a script that has not yet been deployed.

    What is to the right of the #! has no effect on Windows systems, as these find perl using a file type association, or the script gets turned into a .bat file with a different preamble. If the line could be parsed into a perl command and options, e.g. -w these options would be applied.

    Unix systems expect to see the full path to perl. Sometimes #!perl will work via $ENV{PATH}, but this is considered unreliable and insecure.

    The standard script installing mechanism used by ExtUtils::MakeMaker invokes MY->fixin over each script. This will cause your placeholder shebang line to be replaced with a real one that has a path to perl. The fixin method does different things depending on your platform, for example it runs pl2bat on Windows.

    On Unix, fixin does the following:

    • Extract the command and any arguments

    • If the command is the string 'perl' get the interpreter path from $Config{startperl}.

    • Else if there was a different command parsed out, use $Config{perlpath}

    • Otherwise, try and find the perl executable by looking in the path.


    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

Re: Perl interpretation of weird #! line
by blazar (Canon) on Jan 09, 2006 at 08:32 UTC
    To build on Ultra's reply, it may be a directive for a text editor. For example my editor, JED, opens in perl mode based on extension (.pl) and/or shebang line. But for my modules I did not set up an association. I always put a
    # -*- Perl -*-
    comment at the top of them instead.
Re: Perl interpretation of weird #! line
by Ultra (Hermit) on Jan 09, 2006 at 07:16 UTC

    Was that line the first line of a Perl program?

    If that's the case, then the kernel should run what is after the shebang,meaning '@@PERL@@' which I think is an error.

    If not, it is just a comment.

    Dodge This!
      Perl will process any options it finds after the word "perl" on the shebang line. I believe this is case insensitive. So #!@@PERL@@ -w (for example) as the first line of the program should turn on warnings.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://521861]
Approved by neversaint
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2023-09-22 21:18 GMT
Find Nodes?
    Voting Booth?

    No recent polls found