Question: I’m trying to get perl working with the standard “Hello World” script on Dreamhost but I’m new to the language and using CGI. The code I got off is below:

#!/usr/bin/env perl
print “Hello, world”;

The documents tell me that Perl is a interperted language so I Know I don’t need to compile it. From the Dream host KB I found I don’t need the script in a specific directory. I used the extension “.pl”. Is my first line is wrong? Since its off a different website, its probably just a standard file location or maybe I’m not using the right code to tell apache it’s a perl script. If someone could me out I would be greatful…til then I’ll be searching the web! :slight_smile:


I tested the code by telnet. The code still worked for me though as Bob points out the standard is #!/usr/bin/perl

As Bob surmised, I’d say you were trying to get the output to go to a browser and Bob pointed out the commands to do that and the need to turn the script execution on. (chmod)

You might also add an \n after world, but before the closing quote mark. This will add a carriage return after the text. (Though since you’re using a browser now to output the text, you need to add the line:

print “br”;
(with < before the b and > after the r (the html code for carriage return.) for the browser to submit a carriage return.)

(Sorry to say that so goofy. The message board took my br as a command and inserted a carriage return.)

Keep asking questions. This is a good place to do so.


Thanks for the help guys. People have been so helpful in these forums. I do have one other question. To change the script permissions how do I run the chmod? Does everyone have access to the linux command line to do this? I guess I’m not sure how to get to a linux prompt.


Hi Brian.

In the control panel, under users, check the list. If any (or all) say “shell” as the type, you’re set. If you’re on Windows, go to Start…then Run. Type ‘telnet’ (without the quotes and substituting your domain name of course.) Alternately you could type telnet (or whatever your ‘machine’ name is. Thats under ‘machine’ on the user list.)

  1. Then type pwd and press enter.
    That tells you where you’re at.

  2. Type cd plus domain name.
    That moves you there. Example cd

  3. If its in a folder, you could do another cd foldername or simply in one command cd

  4. ls -la will list the files in the directory where you are.

  5. chmod 755 (where is filename) will make the ls -la out beside that filename look like so…

In the case of a script you want Owner (read, write, execute), Group (read and execute), Other (or ‘World’), (read and execute). That translates to chmod 755

(You wouldn’t want the “group” or the “world” to write to your file. They could then modify your script. That would be a bad thing.) But they need to read and run it.

Don’t care to use the shell?

Most (all?) ftp programs offer a way to do this. I use WS-FTP. Once you get logged in via ftp, browse out to the perl script (or whatever file) you want to change permissions on.
Single left click on the filename to highlight it. Then right click, select chmod (UNIX) and check the appropriate boxes.

There’s tons of info on the web explaining all this stuff…better than I can. If you use the shell…type man chmod for instance for more info. But do some unix chmod etc in your favorite search engine for tons of stuff.

(If I don’t reply for a while Ohio is getting a huge ice storm and power is out more than its on.)



Thanks again for the help - When I telneted and did an ‘ls’ I could only see the ‘maildir’ and ‘logs’ directories and some config files but no domain folder. Hmm, maybe I don’t have access that way. I’ll see if I can e-mail support and look at my settings in the web-based account settings. I shows perl access for all accounts so there have to be a way to do it.

Thanks for everyones help, I appreciate the time you’ve spent with me on this.

Ahh, nevermind I figured it out…it was just in the account settings. Thanks again for the help. Today I’m going to go and buy a perl book to help me out with the language so I don’t bug you guys anymore. I’m going to need a book shelf for all the books I have on web development…too many different technologies…

Hi 2ds -

[quote]Today I’m going to go and buy a perl book to help me out with
the language so I don’t bug you guys anymore.


Don’t worry about bugging anyone, that’s what these forums are here for. If people get tired of answering questions, they simply won’t. :>

As for books, if you haven’t purchased one yet, you’ll be best off getting “Learning Perl” by O’Reilly. It’s the #1 way, in my opinion, to learn the language.

As far as programming books are concerned, it’s pretty easy to understand, well written, etc.

  • Jeff @ DreamHost
  • DH Discussion Forum Admin

I’ve been making my way through Sams “Teach Yourself Perl in 24 Hours” and I’m finding it to be excellent. It spends the first half of the book teaching you Perl, and the second half teaching you how to apply that to CGI and web forms.

Really great book.

Sams is good, but O’Reilley’s books are superb - and while this is a good generalization, it is especially good when it comes to Perl, because Larry Wall (who created Perl) works for Tim O’Reilley.

Now that you’ve gotten your feet wet with Perl, you will definitely want to get your hands on “The Perl Cookbook” (also known as the bighorn ram book) ASAP; it has great answers to dumb questions you and I haven’t even thought about yet.

ISBN 1-56592-243-3 $39.95