#! /usr/bin/perl -w # Will Murnane # Copyright (c) 2007 Will Murnane # #Permission is hereby granted, free of charge, to any person #obtaining a copy of this software and associated documentation #files (the "Software"), to deal in the Software without #restriction, including without limitation the rights to use, #copy, modify, merge, publish, distribute, sublicense, and/or sell #copies of the Software, and to permit persons to whom the #Software is furnished to do so, subject to the following #conditions: # #The above copyright notice and this permission notice shall be #included in all copies or substantial portions of the Software. # #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, #EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES #OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND #NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #OTHER DEALINGS IN THE SOFTWARE. use strict; use Data::Dumper; my ($today, $line, $days, $matched, $start, $end, $section, $coursetmp, $prof, $dept, $deptname); my (@courses, @sections, @periods, @classnames); if (($#ARGV < 0) || ($#ARGV > 0)) { die "Usage: " . $ENV{"_"} . " \nExample: " . $ENV{"_"} . " spring2009\n"; } my $semester = $ARGV[0]; `wget http://www.umbc.edu/AboutUMBC/Schedule/$semester/ -O index-file`; open(FILE, "index-file"); while ($line = ) { if ($line =~ /(.+?)$dept.txt"); $get = "no"; while ($line = ) { if ($line =~ /
/) # start grabbing
      { $get = "yes"; }
      if ($line =~ /<\/PRE>/) # donea
      { $get = "no"; }
      $line =~ s/\<.+?\>//ig;
      if ($get eq "yes") { print FILEOUT $line; }
    }
    close(FILEIN);
    close(FILEOUT);
	unlink("$dept.html");
  }
}
$prof = "SMITH, J";
my (undef,undef,undef,$mday,$mon,$year) = localtime(time); $year += 1900;  $mon++;
$today = "$mon/$mday/$year";
print "\n";
print "\n";
for my $arrref (@classnames)
{
  ($dept, $deptname) = @$arrref;
  open(FILE, "$dept.txt");
  @courses = ();
  READ: while ($line = ) {
  #  print $line
    $matched = 0;
    $line =~ m/^$/ && next READ;
    if ($line =~ m/$dept\s*(\w+)\s*(.+?)\s+(\d)(.\d)? credits/)
    { 
      defined $section && ($#periods > -1) && push @sections, $section . join("", @periods) . "    \n";
      @periods = ();
      if ((defined $coursetmp) && ($#sections > -1))
      {
        push @courses, $coursetmp . join("", @sections) . "  \n";
      }
      @sections = ();
      $coursetmp = "  \n"; $matched = 1; 
    }
    if ($line =~ m/^\[(\d{4})\] (\d{4})(.*)(\s{3,}(.+))/)
    {
            (defined $5) && ($prof = $5);
            defined $section && ($#periods > -1) && push @sections, $section . join("", @periods) . "    \n";
            @periods = ();
            $section = "    
\n"; $matched = 1; } if ($line =~ m/([M|Tu|W|Th|F|S|U]+)\.*(\d+:\d+[ap]m)\s*-\s*(\d+:\d+[ap]m)\s*\(.+\)(\s{3,}(.+))?/) { $days = $1; $start = $2; $end = $3; $days =~ s/M/mon/; $days =~ s/Tu/tue/; $days =~ s/W/wed/; $days =~ s/Th/thu/; $days =~ s/F/fri/; $days = join(",", grep { $_ !~ /^\s*$/ } split(/(...)/, $days)); push @periods, " \n"; # print $periods[$#periods-1]; $matched = 1; } if ($line =~ m/Grade Method: (.+)/) { next READ; } if ($line =~ m/^\ {11}/) { next READ; } } defined $section && ($#periods > -1) && push @sections, $section . join("", @periods) . "
\n"; @periods = (); if ((defined $coursetmp) && ($#sections > -1)) { push @courses, $coursetmp . join("", @sections) . "
\n"; } @sections = (); if ($#courses > -1) { print "\n"; print join("", @courses); print "\n"; } close(FILE); unlink("$dept.txt"); } print "
";