GetOptions(\%opts, 'schedule=s', 'grades=s', 'name=s', 'format|f=s', 'config|F=s', 'out|o=s');
if (-r $opts{'config'}) {
- open CONFIG, $opts{'config'};
+ open CONFIG, $opts{'config'} or die $!;
while(<CONFIG>) {
s/\#.*//;
next unless m/^([^=]*)=(.*)/;
sub get_faculty_email {
my ($name, $school, $email);
if((-f $ENV{'HOME'} . "/public_html/faculty.csv") && ! %faculty) {
- open INS, $ENV{'HOME'} . "/public_html/faculty.csv";
+ open INS, $ENV{'HOME'} . "/public_html/faculty.csv" or die $!;
while($_ = <INS>) {
chomp;
m/"([^"]*)",([^,]*),([^,]*)/; # "
my @lines;
foreach my $name (<$file/[1-9]*>) {
next unless $name =~ /^$file\/[1-9][0-9]*$/;
- open FH, $name;
+ open (FH, $name) || die $!;
@lines = <FH>;
close FH;
foreach (@lines) {
my $i=0;
foreach (@mhc) {
while(-f ++$i) {}
- open FH, ">$file/$i" or die $!;
+ open (FH, ">$file/$i") || die $!;
print FH $_;
close FH;
}
} else {
- open(STDOUT, ">" . $file) if(defined($file));
+ open(STDOUT, ">" . $file) || die $! if(defined($file));
print "# MHC school schedule\n# Autogenerated by sctweb ".localtime()."\n\n";
print join("\n", @mhc);
}
my @mon = qw(Jan. Feb. Mar. Apr. May June July Aug. Sept. Oct. Nov. Dec.);
my ($current, @mhc, @schedule);
@schedule = get_schedule(@_);
- open(STDOUT, ">" . $opts{'out'}) if(defined($opts{'out'}));
+ open(STDOUT, ">" . $opts{'out'}) || die $! if(defined($opts{'out'}));
foreach my $row (@schedule) {
map {s/\n/-/g if defined; $_} %$row;
my $id=generate_id($row->{'id'});
my %days = (M => "MO", T => "TU", W => "WE", R => "TH", F => "FR", S => "SA", U => "SU");
my $file = $opts{'out'};
my @schedule = get_schedule(@_);
- open(STDOUT, ">>" . $file) if(defined($file) && (! -d $file));
- open(STDOUT, ">/dev/null") if(defined($file) && (-d $file));
+ open(STDOUT, ">>" . $file) || die $! if(defined($file) && (! -d $file));
+ open(STDOUT, ">/dev/null") || die $! if(defined($file) && (-d $file));
print "BEGIN:VCALENDAR\r\nVERSION:1.0\r\n";
foreach my $row (@schedule) {
map { s/\n/-/g; $_} %$row;
my $schedule = { class => [ get_schedule(@_) ] };
my $xml = XMLout($schedule, NoAttr => 1, RootName => 'schedule');
if($file) {
- open FH, ">$file";
+ open FH, ">$file" || die $!;
print FH $xml;
close FH;
} else {
my $shade = "dark";
my @schedule = get_schedule(@_);
if($opts{'out'}) {
- open FH, ">" . $opts{'out'};
+ open (FH, ">".$opts{'out'}) || die $!;
select FH;
}
print '<table id="schedule" cellpadding="3" cellspacing="0">'."\n<tr><th>";
my ($row);
my $shade = "dark";
if($opts{'out'}) {
- open FH, ">" . $opts{'out'};
+ open (FH, ">".$opts{'out'}) || die $!;
select FH;
}
print '<table id="grades" cellpadding="3" cellspacing="0">'."\n<tr>";
} else {
die "Unknown format. Try specifying --format.\n"
}
-