#!/usr/bin/DONOTRUN/perl -w

# This is a fragment from one of my scripts which I use to help grade.
# Do NOT attempt to run this code.  It is incomplete and could do very 
#   bad things to your directories, since you haven't permission to my
#   files or directories.
# I've even altered the shebang above so that it will be extremely difficult
#   for you to run this code.
# It is meant simply as a more complex example of Getopt::Long, File I/O,
#   and Directory I/O.
#


use Getopt::Long;

$HANDIN = '/p/course/cs302/handin/whiteman';
$COPYDIR = '/u/w/h/whiteman/private/cs302/grading/sp03';
$ROSTER = '/p/course/rosters/cs302-whiteman/cs302-004-000.logins';
$JAVABOOK = '/u/w/h/whiteman/private/cs302/grading/javabook2.jar';

#there are lots of options here.  you can string together as many options
#  as you want.  just keep them straight
GetOptions("verbose" => \$verbose, "lesson=s" => \$lesson, "setup" => \$setup, 
           "copy" => \$copy, "compile" => \$compile, "javabook" => \$javabook,
	   "mcompile" => \$mcompile);

#here we open a file, and read it in all at once
open($ROSTERFILE, "< $ROSTER") || die ("Can't open roster directory!  $!");
@students = <$ROSTERFILE>;
close $ROSTERFILE || die ("Can't close roster directory!  $!");

#below are examples of directory functions chdir and mkdir.
if($setup)
{
  chdir $COPYDIR;
  foreach(@students)
  {
    chdir $COPYDIR;
    chomp;
    mkdir $_, 0700;
    chdir "$COPYDIR/$_";
    foreach(1..8)
    {
      mkdir "L$_", 0700;
    }
    foreach(1..2)
    {
      mkdir "A$_", 0700;

    }

  }
}
