Return to lecture notes index

September 11, 2007 (Lecture 5)

Lab Submission

Today we went over how to submit your homework. We explained how to submit your labs from one of the cmu cluster machines. The tool we use here is terminal.

Log into a cluster machine using your andrew id and password and open up terminal. The first thing we have to do is get into the handin directory. We use the cd command followed by the file path.

This will bring you into the handin directory. From here we can type ls to see the folders in the handin directory. Let's assume we're turning in Lab1. Let's cd into the lab1 folder. We can also use the command pwd to show you what directory you are currently in. Now that we're in the lab1 directory, make a new directory using your andrew id as the folder name. The command for this is mkdir . For example: Now we get to actually submit the file. To copy a file we use the command: cp ~ Since we are already in the directory you want to copy to, we can replace the second filepath with a period '.' . Let's say the file is on your desktop and called HelloWorld.
  • cp ~/Desktop/HelloWorld .
  • ls should should now display the file HelloWorld
Now your lab is submitted.

15-123 Policies on Submission

As a general rule, 15-123 only supports submission from lab machines. SSH Secure Shell also works if you are interested in accessing this from your personal machine, however you will have to find out how to use this on your own or ask a friend, as we do not support it.

Another important thing to note is that drag and drop programs like finder do not work. The method they use to copy files generally results in an empty file being submitted instead. Do not use these.

If you have already submitted a file, made some changes and want to resubmit, just make a new folder in the lab# folder with a new version number. For example, gkesden.2. We will only grade the latest version.

Refer to the syllabus on the course webpage for the late submission policy

A Bit More Perl: chomp()

When reading data from the user or from a text file, you will often find that the resulting string is terminated with a newline. This newline is present because, although it is interpreted as delimiter, it is not automatically stripped by Perl.

Stripping the newline is easy with the chomp() function. Check out the example below:

  $text =  # The user enters "hello[RETURN]", the return is the \n
  chomp $text # The \n is present at the end of the line, but removed by chomp

It is important to note that chomp() only removes the newline if it is the last character in the string -- it will nto remove newlines in other places.

It is also important to note that chomp() is not hardwired to remove newlines. Instead it removes instances of the so-called "input record separator (IRS), which is, by default, a newline. But, this can be changed. For those who like connecting the dots, Perls IRS is much like AWKs RS, except that AWK's RS can be a regex and Perl's IRS is a simple string.

The IRS is represented in Perl as "$/". It is treated as a variable and can be assigned as in the example below:

  $/ = "\r";

Although we didn't talk about it in class, you'd want to "localize" this variable before changing it. In other words, you'd want to tell Perl that your part of the code should have its own copy -- or you change could affect other modules, such as those that are part of libraries.

  local $/ = "\r";

Don't Confuse chop()

The chop() function removes and returns the last character of a string. If that last character happens to be the RS, it works like chomp(). But, it is important to note that chop() doesn't care what it eats.

chop() is also a bit weird, in that if you hand it an array -- it chops the last character off of --each and every-- element of the array.