Problem getting Perl to run

software development

#1

ok, I haven’t had a whole lot of experience with perl, but I’ve been looking through some tutorials and yet I still can’t get it to work. I’m just trying to get a basic hello world program to run, as below:
#!/usr/bin/perl

Program to do the obvious

print ‘Hello world.’; # Print a message
but whenever I try to run it in my ssh terminal I get the following
[tartarus]$ ./perltest.pl
: bad interpreter: No such file or directory

I’ve changed the permissions to 755 so that should be fine, and I’ve tried #!/usr/bin/perl, #!/usr/bin/perl5.8.4 (which I saw in the /usr/bin/ directory), and #!/usr/local/bin/perl, and they all give me the same thing. I’ve also tried doing this in a random directory, and in a cgi-bin directory.

I’m not sure if this means there is a problem with the actual perl interpreter or if I’m doing something wrong. Any help would be greatly appreciated.


#2

[quote]#!/usr/bin/perl

Program to do the obvious

print ‘Hello world.’; # Print a message[/quote]
That exact code runs just fine for me, so you must have something going on.

What editor are you using to create the file, and what directory is it in?

–rlparker


#3

Arg, Windows seems to have done it again.
I originally made the file with Wordpad in Windows, but had since edited it with vi, so I thought it would be fine from that angle, but alas as I have just found out, it worked fine when I remade it in vi.
Thanks for your quick response and analysis :slight_smile:


#4

Ha ha! That does happen!

I understand completely, and most of us have done that at one time or another. :wink:

I was happy to provide a “hint”, and I’m glad you got it working! :slight_smile:

–rlparker