your first perl program in eclipse
Now that you have spent so much time getting Eclipse working, it is time to try your first program.
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 in the first tutorial.
- Select Ambient > Snarf.
- This should open a new tab at the bottom called Snarf Browser. If it does not:
- Select Window > Show View > Other...
- Click Duke Tools then select Snarf Browser and hit ok.
- Right-click in the Snarf Browser window, and select New Site.
- In the window type http://www.cs.duke.edu/courses/cps160/spring05/snarf/.
- Click through the list until you find first, and double click on it.
- Click the Install Project... button, and in the window that pops up check the Use Default box, and click Next then Finish.
- You can then double-click first perl program in the Navigator window near the upper left head corner of the program and then double click first.pl.
- If you do not see a Navigator window, it could be that you are in the wrong
perspective. If this is the case:
- Select Window > Open Perspective > Other...
- Select Perl then hit OK.
2.) Now we will try running the simple Perl program that you downloaded.
- Click the button in the bar at the top that looks like a green circle with a white arrowhead and a red suitcase in front of it.
- This should create a Console tab at the very bottom. If it does not:
- Select Window > Show View > Other...
- Click Basic then select Consle and hit ok.
- Click the Console tab.
- At the command prompt, type perl first.pl.
- You can see the program run printing out the minimum and maximum values of the array.
- Type exit to stop the console. Otherwise, it will continue running the command prompt, using up your machine's resources.
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.