Computer Sciences Department logo

CS 368-1 (2011 Summer) — Day 1 Homework

Due Tuesday, July 12, at the start of class.

Description

Run a Perl script on your machine and print the output.

Details

Really, this exercise is all about making sure that you have a working Perl environment to use for the rest of the class. So, try these steps:

  1. Find/pick a machine to work on
  2. Set up a working directory on that machine
  3. Save the Perl code in a file named "homework-01.pl"
    #!/usr/bin/perl
    # Homework for CS 368-1
    # Assigned on Day 01, 2011-07-11
    # Written by [Your Name Here]
    
    use strict;
    use warnings;
    use Sys::Hostname;
    use POSIX 'strftime';
    print "CS 368 homework 01\n";
    print "time     = '" . strftime('%Y-%m-%d (%a) %H:%M:%S %Z', localtime()) . "'\n";
    print "hostname = '" . hostname . "'\n";
    print "program  = '$0'\n";
    print "exec     = '$^X'\n";
    print "version  = '$]'\n";
    # remove the last line if using Windows
    print "username = '" . (getpwuid($<))[0] . "'\n";
  4. Try running the script like this:
    perl homework-01.pl
  5. If it fails, ask someone you know or the instructor for help
  6. Once it works, read below for what to hand in

Reminders

Normally, you will do each homework by yourself. But in this case, you may ask for help from anyone who knows how to get Perl running on your machine. Be sure to use a machine that you can use for the rest of the class, because you really want to make sure Perl is working right…

Hand In

A printout of your output on a single sheet of paper. Be sure to put your own name in the “[Your Name Here]” part of the code. Identifying your work is important, or you may not receive appropriate credit.