Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

#!/usr/bin/perl -w versus #!/usr/bin/perl

#!/usr/bin/perl -w versus #!/usr/bin/perl

#!/usr/bin/perl -w versus #!/usr/bin/perl

I'm wondering if anyone can clarify this for me:

When I was first learning Perl I started all my files off with a fairly basic shebang line:



My ActivePerl was installed in C:\Perl\bin\perl but Windows didn't care because it was going by file extensions, but when uploaded to *nix servers this line would work fine.

I had a web host once on a Linux server and my scripts were all giving these 500 Internal Server Errors. The files were formatted correctly and uploaded correctly, had the correct permissions to execute, but I couldn't tell what the problem was and so I searched the forums of this web hosting company. Somebody said to change the shebang line to this:


#!/usr/bin/perl -w

Sure enough, adding the -w flag allowed the script to execute just fine.

Because of that I got into the habit of always using -w in my shebang line, and every once in a while I'd have someone ask me why their CGI isn't working and I'd take a look, recommend them to add the -w and then it starts working. But the last time I actually encountered this problem was years ago.

My brother (who's not much of a programmer) was putting together a basic Perl script to e-mail him the results of a form. It wasn't working on his server so he sent me it. He had it formatted in Unicode and so Perl was complaining about unrecognized characters, so I converted it to ASCII and then Perl complained of syntax errors. Fixing them, the Perl syntax check passed just fine. So then I tested the CGI on my local Apache server running on my Fedora 9 machine, and it was giving me these server errors.


File not found: can't exec '/home/kirsle/public_html/test/member.pl'
Premature end of script headers at /home/kirsle/public_html/test/member.pl

(the error was something to that extent... my VPS web server running CentOS 5 with a custom build of Apache doesn't mind the absence of -w, and my work PC running Fedora 9 [possibly with a custom Apache] doesn't mind either, but my home PC running Fedora 9 does as does various web servers I've encountered over the years)

Why do some servers require a -w on this line and give a server error if it's not there?

Cuvou.com | My personal homepage


perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'

RE: #!/usr/bin/perl -w versus #!/usr/bin/perl

I have 5-10 servers running all different kinds of apache configurations and none of them require the -w, but I know my web host does.  So I'm wondering if it's a apache requirement/configuration of some kind.  Let us know if you find anything out :)

Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;

RE: #!/usr/bin/perl -w versus #!/usr/bin/perl

Sounds like a Fedora 9 problem. Maybe ask on a forum that specializes in that particular OS.

- Kevin, perl coder unexceptional! wiggle

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close