<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl

# This script fingers @lsc.mit.edu to get the LSC events 
# for the next week, and pulls out relevant information.

# Grab finger output
my @lines = `finger \@lsc.mit.edu`;

# Get rid of "Welcome to lsc.mit.edu!" banner
shift(@lines);
shift(@lines);
shift(@lines);
shift(@lines);
shift(@lines);

# Open file for writing
open(LSC, '&gt; /var/www/processed/lsc-tmp.html');
print LSC '&lt;a href="http://lsc.mit.edu"&gt;';

# When $title, grab the line.  Otherwise, it's not the title.
my $title = 1;

# Go through by each line and trim and touch up as needed
for (my $i=0; $i&lt;=$#lines; $i++) {  # Iterate over the array
  # If we've finished the listings, abort
  if ($lines[$i] =~ /Administrivia/) {
    $i = $#lines;
  }
  # Otherwise, strip title and write to the file
  else {
    if ($title) {			# Write to file
      # Skip to the title of whatever the special event is
      if ($lines[$i] =~ /Upcoming Special Event at LSC/) {
        $i++;
      }
      print LSC "$lines[$i]&lt;br&gt;";
      $title = 0;
    }
    elsif ($lines[$i] eq "\n") {	# Blnk line - reset flag
      $title = 1;
    }
  }
}

#    $orig =~ /(\d\d:\d\d:\d\d)/;        # and make it look pretty
#    my $time = $1;
#    my @info = split /\d\d:\d\d:\d\d/, $orig;   # split route and stops info

# Close file and exit
print LSC "&lt;/a&gt;";
close(LSC) || die("Couldn't close file");

# Replace temporary file
`mv /var/www/processed/lsc-tmp.html /var/www/processed/lsc.html`;

</pre></body></html>