DAT2322 - Course Notes

Introduction to Computer Programming


Lesson 1

Instructions to Create and Run a Perl Program in Windows 95/98

  1. Composing the Perl source program.
  1. Start NotePad. In a new document, type in the following code:

    
    # hello.pl	This program prints a hello message.
    #
        print "Hello World !";
    
     
    You must type carefully

    Type all code and commands exactly as shown. "print" cannot be typed as "Print". They are not the same as Perl is case-sensitive. If you forgot the last semi-colon (;), the program will not work right.

  2. Save this code to a file. From the menu bar, select File > Save As.
    In the Save As dialog box:

    • Using the Save in drop-down menu, specify the a: drive (or n:) where you'll save your file.
    • In the File name text box, type "hello.pl", including the double quote marks.
    • From the Save as type drop-down menu, choose Text Document. 

    When you're finished, the dialog box should look like this:

    Now click Save, and exit NotePad.
2. Run the Program

  From the Start menu, select the MS-DOS Prompt application.

When the application launches, it should look like this:

The prompt shows your current directory. When you bring up the prompt for Windows 95/98, your current directory is usually WINDOWS on your C drive (as shown above). To run your source code file, change your drive to A: (or N: if you don't have a usable diskette), you would type the following command at the prompt and press Enter:

 a: 

Now the prompt should change to A:\>.

If you enter dir at the prompt, you should see your file.

 dir: 

Now you can run the Perl program. At the prompt, type the following command and press Enter:

 perl hello.pl  
Now you should see:

Congratulations! Your program works.
 
The best way to work with Perl programs is to place the Notepad window on the top half of the desktop screen and the Perl window on the bottom half. Switch to the Notepad window for composing and modifying your program. Switch back to the Perl window to run it and see the result.
  | To top |
M. Mark, 2000.03.04 | Introduction | Lesson 1 | Lesson 2 | Lesson 3 | Lesson 4 | Appendix |