Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Debugging: What's going on here?

by Kozz (Friar)
on May 23, 2000 at 20:15 UTC ( #14395=perlquestion: print w/replies, xml ) Need Help??
Kozz has asked for the wisdom of the Perl Monks concerning the following question:

I've got a small perl script which has been giving me an error, so I made a copy of it and began removing large chunks of it. Believe it or not, I am now left with a "Hello, World!" script that's giving me errors?
#!/usr/bin/perl print "Hello, world!\n";
and the error I get is
$ ./ bash: ./ No such file or directory
Want to know what's even funnier? If I run this script with "-w" then it runs fine. I've typed & retyped the #!/usr/bin/perl several times to make sure there werent' any funky characters in there. What's going on? This must be something with my environment, and not the script?

Replies are listed 'Best First'.
Re: Debugging: What's going on here?
by mdillon (Priest) on May 23, 2000 at 20:23 UTC
    it sounds like /usr/bin/perl is not the path to your perl interpreter (the error message is coming from bash, not perl). if you are able to type "perl" on the command line and get an interpreter, you should be able to change the first line to "#! perl -w" and get it to work.

    to figure out the location of your perl interpreter, type "which perl" at the bash prompt.

    also, try to run "perl", instead of relying on bash to figure it out, and see if you still have problems.

Re: Debugging: What's going on here?
by jjhorner (Hermit) on May 23, 2000 at 20:22 UTC

    I copied and pasted your code and it worked.

    A few things to try:

    • Start with a new file, and paste the code above into it, then 'chmod u+x' and './'. That worked for me.
    • Please check for the silly things: paths, filenames, current directory location, etc. These things get even the best.
    • If all else fails, make sure you aren't using the wrong location for your perl executable.

    There isn't much else to try, I think.

    J. J. Horner

    Linux, Perl, Apache, Stronghold, Unix

I must be going *insane*!
by Kozz (Friar) on May 23, 2000 at 20:24 UTC
    I used a carriage-return-stripping script on this "Hello, World" script, and then there were no errors. But I'm editing it in VI (well, VIM), and usually these pesky characters show up as ^M. But they weren't visible. How strange. I feel sooo foolish, though. Why couldn't I see those darn \r's?
      vim automatically recognizes DOS-style end-of-lines and treates them correctly. To force it to use unix-style EOLs, set the "filetype" variable to "unix":
      :set ff=unix
      Then write the file. It will write it in Unix format. If you set ff=unix before loading a file, it should show the \r's as ^M.


RE: Debugging: What's going on here?
by dempa (Friar) on May 23, 2000 at 20:25 UTC
    OK, this is just a shot in the dark, but are you sure your perl binary is in /usr/bin ? I use both Solaris and Linux, and in Solaris the perl binary is located in /usr/local/bin. So every now and then, I type in the wrong path in the she-bang line.

    As I said, a shot in the dark...

RE: Debugging: What's going on here?
by Apterigo (Scribe) on May 24, 2000 at 03:45 UTC
    The most natural cause for this error message is that /usr/bin/perl is not where perl is located. Run the command 'which perl' and then copy and paste the result into your she-bang line in the perl script. If that still doesn't work, you may want to just manually run the perl script.
Re: Debugging: What's going on here?
by KM (Priest) on May 23, 2000 at 20:21 UTC
    Have you checked the permissions? chmod +x

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://14395]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2017-10-19 06:46 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (251 votes). Check out past polls.