Installing Eclipse

Recommended:

Click this link to install locally available Duke Computer Science distributions of Eclipse. These copies of Eclipse include the Ambient and Epic plugins required to snarf and submit code for your problem sets, and to run Perl within Eclipse.

For experts:

If you choose to download the latest version of Eclipse and install Ambient yourself:

Installing Perl

Once you have Eclipse installed on your computer, you will need to install the libraries that are necessary to run Perl. These come preinstalled in UNIX and Mac OS X, so if you have one of those operating systems, you don't need to do anything here.

One of the most popular libraries for this is ActivePerl. The current version is 5.11.1. But to maintain consistency among Mac and Windows users we will use version 5.8 in this class.

Download and install ActivePerl 5.8.9.827:

Your first Perl program in Eclipse

Let's try making your first Perl program in Eclipse.

First ensure that you have the right perspective in Eclipse. The Perl perspective will give you a less cluttered set of windows with the smaller Navigator and Outline on the left and the main editor window on the right.

The Ambient plug-in allows one to browse code online by using a tool called Snarf. Basically, we will provide you with some code as a framework and possibly some data files for each homework assignment and Snarf will allow you to import these files into your local copy of Eclipse. To start your first program, follow the directions below.

  1. Open Eclipse after setting up everything as described above.
    • Select Ambient > Download (Snarf) a Project....
    • This should open a new tab at the bottom called Snarfer Site Browser. If it does not:
      • Select Window > Show View > Other...
      • Click Ambient then select Snarfer Site Browser and hit ok.
    • Right-click within the Snarfer Site Browser window, and select New Site.
    • In the window type http://www.cs.duke.edu/courses/cps160/fall10/snarf/
    • Expand the project site CPS 160 Fall 2010, click through the list by expanding the folders until you find first perl program (1.0), and double click on it.
    • Click the Install Project button, and in the window that pops up check the use default workspace location box, and click Finish.
    • The "Import project ..." window will come up. Leave the fields unchanged and click Finish.
    • You can then double-click the first perl program project in the Navigator window, on the upper left of the main editor window and then double click first.pl.
  2. Now we will try running the simple Perl program that you downloaded.

    • Click on the Run icon on the toolbar (the green circle with the white triangle pointing right) to run the program.
      This should create a Console tab at the very bottom and the results of the program should be printed in it. If the console does not appear:
      • Select Window > Show View > Other...
      • Click General then select Console and hit ok.
    • Alternatively select Run from the Run menu.
    • Alternatively right click anywhere within the body of the program. Click on Run As > Perl Local.

    You can just repeat step 2 every time you edit the program. For each assignment, we will provide a codebase for you to work from, which you will always be able to import by Snarfing.

  3. You should also notice that PerlDoc is available from Eclipse. Just double-click on "print" and then choose Help > Perldoc (or use the shortcut Shift+Ctrl+H).

Submitting a sample project

Now you will try to modify the program and then submit the code from within Eclipse.

  1. Modify the file first.pl to print out the minimum and the maximum value:
    • Add another line:print "The maximum value is: $maxval.\n";
    • Save the file (Ctrl+S).
    • Run first.pl again, to see if it prints out the maximum.
  2. Submit the project.

    Select Ambient>Submit a Project for Grading... This will bring up a submit window. First you have to choose the class and assignment you wish to submit to. Click on cps160, select the test folder and then click Next. Select the "Submit from the file system" option, click on the name of project that you wish to submit and then hit Next. You should now see all the directories and files in the current project. Check only the Perl files (first.pl, cps160lib.pm) and then click Finish. You will be asked to enter your Duke NetID (ACPUB ID) and password. Congratulations, you have submitted your project!

    You can submit as many times as you like, as everything is stored on the server. Thus, if you realize that you did something wrong at the last minute, you can resubmit and we will only look at your last submission. When you resubmit a project, please resubmit all the Perl files, not just the ones you modified.