Jump to content

Do I need append first line to every source code?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
ReekenX

ReekenX

    Programmer

  • Members
  • PipPipPipPip
  • 134 posts
Hello all.

I am new to PERL. I have question about this line:

#!/usr/local/bin/perl

Does all perl source files must be with that same line (path to compiler of perl)? What if path in other host is not the same as in others? I know that this line tells to run the file through Perl.
www.jarmalavicius.lt | www.github.com/reekenx | www.twitter.com/reekenx

#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
Your file doesn't need or require it, so you can leave it out. What it does is to tell where the Perl-interpreter is located, so that you can run the script with a double-click or similar.

#3
ReekenX

ReekenX

    Programmer

  • Members
  • PipPipPipPip
  • 134 posts
So I can write PERL scripts without these lines? And it will work?
www.jarmalavicius.lt | www.github.com/reekenx | www.twitter.com/reekenx

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
If you do not include it you will not be able to execute the Perl script with "./scriptname.pl" and will have to call it as "perl scriptname.pl". It will also not work via the web executed from Apache/your webserver software.

#5
ReekenX

ReekenX

    Programmer

  • Members
  • PipPipPipPip
  • 134 posts
But what if I move script to other server where value of this first line
#!/usr/local/bin/perl
will be other? I will must replace these lines by hand or what?
www.jarmalavicius.lt | www.github.com/reekenx | www.twitter.com/reekenx

#6
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Yes. Or you could create a symbolic link in /usr/local/bin/ to the new location of Perl (only in Linux).

#7
ReekenX

ReekenX

    Programmer

  • Members
  • PipPipPipPip
  • 134 posts
Big thanks Jordan. What is symbolic link? Its made by .htaccess:
Options FollowSymlinks
or what?
www.jarmalavicius.lt | www.github.com/reekenx | www.twitter.com/reekenx

#8
Guest_Jordan_*

Guest_Jordan_*
  • Guests
It is done at the operating system with the command: "ln -s /path/to/link".

#9
ReekenX

ReekenX

    Programmer

  • Members
  • PipPipPipPip
  • 134 posts
Ok, thanks Jordan for answers.
www.jarmalavicius.lt | www.github.com/reekenx | www.twitter.com/reekenx

#10
KevinADC

KevinADC

    Programmer

  • Members
  • PipPipPipPip
  • 125 posts
Easier to just edit the shebang line than changing the server configuration, unless you are the server administrator that is.

Apache can also be setup to not use the shebang line, but again, this is a server configuration and you may not be able to edit the apache config file or restart the apache server.

#11
Guest_Jordan_*

Guest_Jordan_*
  • Guests
This is true, you will need root access to accomplish these things. Why does the shebang line concern you?