# Perl heads: Help!

**URL:** <https://boards.straightdope.com/t/perl-heads-help/95534>\
**Category:** Factual Questions\
**Created:** [November 27, 2001, 4:44pm UTC](https://boards.straightdope.com/t/perl-heads-help/95534 "2001-11-27T16:44:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![occ](https://avatars.discourse-cdn.com/v4/letter/o/8c91f0/32.png) [@occ](https://boards.straightdope.com/u/occ)\
**Post date:** [November 27, 2001, 4:44pm UTC](https://boards.straightdope.com/t/perl-heads-help/95534/1 "2001-11-27T16:44:41Z")

</div>

I know how much everyone loves answering specific tech-support questions in threads, so why not take on this little gem?

I manage a web server. From time to time, we install various CGI scripts. No big deal.

Anyway, I upload my scripts. I chmod them to 0755. The file in question, let’s call “install.pl”.

I’m in the directory in question. I’ll do a ls, and get this result:

\<other files, blah blah\>  
install.pl

So there’s the file. It’s executable. When i try this command:

./install.pl

I get this error:

bash: ./install.pl: No such file or directory

I check the first line of install.pl:

#!/usr/bin/perl

Looks normal to me, but hey, might as well check it. Back at the command line, I execute the following command:

/usr/bin/perl install.pl

And the script runs fine. So here’s my question: why the hell is this happening? The file’s there, its executable, and Perl can even see the file. This has nothing to do with this specific script, since its come up in times past. I can create a blank script beginning with the same Perl path, and it will work fine. Anyone else ran into this in the past, or have any ideas? Even the tech support at the webhost has no ideas.

---

<div class="post-metadata">

**Author:** ![skripek](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@skripek](https://boards.straightdope.com/u/skripek)\
**Post date:** [November 27, 2001, 5:01pm UTC](https://boards.straightdope.com/t/perl-heads-help/95534/2 "2001-11-27T17:01:52Z")

</div>

My Bourne is a little rusty, but I would guess that one of the permissions is incorrect. You did say you chmod’ed the file…so that is indeed weird.

Perhaps it’s a configuration problem in your .bash\_profile?

---

<div class="post-metadata">

**Author:** ![occ](https://avatars.discourse-cdn.com/v4/letter/o/8c91f0/32.png) [@occ](https://boards.straightdope.com/u/occ)\
**Post date:** [November 27, 2001, 5:11pm UTC](https://boards.straightdope.com/t/perl-heads-help/95534/3 "2001-11-27T17:11:59Z")

</div>

Well, I’m only running the script manually because Apache refused to run it in the first place. However, Apache will run other scripts, and if I write a little “Hello, World!” script, chmod it exactly as the non-working script, and stick it in the same directory, Apache _will_ run it.

Another thing I thought of: could this possibly have something to do with the different types of line breaks used by Windows/Unix? A long shot, I know, but I’m running out of ideas.

---

<div class="post-metadata">

**Author:** ![skripek](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@skripek](https://boards.straightdope.com/u/skripek)\
**Post date:** [November 27, 2001, 5:33pm UTC](https://boards.straightdope.com/t/perl-heads-help/95534/4 "2001-11-27T17:33:32Z")

</div>

The line breaks could indeed be your problem.  
If you have access to a hex editor, look to  
see if there is a 0d-0h at the end of each line.  
I recall having a similar problem in the past that  
was the opposite (windows barfed on the unix file).

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [November 27, 2001, 5:50pm UTC](https://boards.straightdope.com/t/perl-heads-help/95534/5 "2001-11-27T17:50:29Z")

</div>

First, make sure you uploaded it in ASCII mode.

Next, check the shebang (#!) line of install.pl. That error _usually_ indicates that the shell can’t find the intepretor. (The No such file is talking about the Perl interpretor, not the script.) Type ‘which perl’ at the command line to find the correct path to perl and alter the shebang line as necessary.

---

<div class="post-metadata">

**Author:** ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)\
**Post date:** [November 27, 2001, 8:18pm UTC](https://boards.straightdope.com/t/perl-heads-help/95534/6 "2001-11-27T20:18:57Z")

</div>

I agree with the earlier replies. When I’ve had this problem it was because of the differing DOS and Unix line-break conventions. DOS uses \<CR\> \<LF\> (0Dh 0Ah) and Unix uses just \<LF\> (0Ah). This means that the first line of your script is being interpreted by Unix as

#!/usr/bin/perl\<CR\>

which has an extra \<CR\> character in the filename.

A lot of Unix/Linux installations have a program “dos2unix” which will remove the extra carriage returns. You can also use the Unix standard command “tr”:

tr -d ‘\015’ \< install.pl \> newinstall.pl
