CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
The first line..

 



tabarry
New User

Feb 26, 2009, 12:36 AM

Post #1 of 6 (1089 views)
The first line.. Can't Post

Hello,

Usually, the first line of a perl script is #!/usr/bin/perl.

Now my problem is that this is the path to perl on my server but it is not the same on the other server where I upload it.

When I move files from my system to the online server, I have to change this path on every file.

Is there a way that we out for this?


gnix
Novice

Feb 26, 2009, 1:11 AM

Post #2 of 6 (1088 views)
Re: [tabarry] The first line.. [In reply to] Can't Post

Maybe, you can replace '/usr/bin/perl' with 'which perl', but I don't know if it works.

gnix


BeemerBiker
Novice


Feb 26, 2009, 8:53 AM

Post #3 of 6 (1082 views)
Re: [tabarry] The first line.. [In reply to] Can't Post

I have been using that same #!/usr/bin/perl -w even though it should have been

#!C:\Perl64\bin\perl.exe -w

It has been amazingly working (the usr/bin stuff), both on vista-64 and on ubuntu. If you find out what it is good for let me know. I have found that "use strict;" which seems to really do something unlike that "-w".



HTH


(This post was edited by BeemerBiker on Feb 26, 2009, 9:24 AM)


KevinR
Veteran


Feb 26, 2009, 11:02 AM

Post #4 of 6 (1079 views)
Re: [BeemerBiker] The first line.. [In reply to] Can't Post


In Reply To
I have been using that same #!/usr/bin/perl -w even though it should have been

#!C:\Perl64\bin\perl.exe -w

It has been amazingly working (the usr/bin stuff), both on vista-64 and on ubuntu. If you find out what it is good for let me know. I have found that "use strict;" which seems to really do something unlike that "-w".

Thats because Windows does not use the shebang line to find perl, although it will read the shebang line to load some switches, like -w.

If you run CGI scripts on Windows the http server might need the shebang line to be correct.


HTH

-------------------------------------------------


tabarry
New User

Mar 2, 2009, 7:43 PM

Post #5 of 6 (1065 views)
Re: [KevinR] The first line.. [In reply to] Can't Post

Thanks!


1arryb
User

Mar 3, 2009, 6:52 AM

Post #6 of 6 (1060 views)
Re: [KevinR] The first line.. [In reply to] Can't Post

Just to summarize.

The "shebang" is a line at the top of an executable script that starts with the characters "#!".

What comes after is supposed to be the path to the program that should be used to execute the script (e.g. "/usr/bin/perl", "/bin/bash", etc.).

Only L/Unix systems (and cygwin on windows) look at the shebang.

Windows uses a different system : On Windows, the operating system associates file extensions with executable programs (e.g. ".pl" --> perl.exe). The associations between extensions and executing programs are stored in the Windows registry.

The goal in both cases is to obviate having to type "perl " at the beginning of each command line (or, on GUI systems, having the system ask you what you want to do when you double-click on a file).

Kinda obsolete at this point, but hey! It's tradition.

Cheers,

Larry

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives