projects
/
tpope-extra.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3a174b4
)
Error checking on file opens
author
Tim Pope
<code@tpope.net>
Sat, 20 Aug 2005 05:57:25 +0000
(
05:57
+0000)
committer
Tim Pope
<code@tpope.net>
Sat, 20 Aug 2005 05:57:25 +0000
(
05:57
+0000)
perl/schedproc
patch
|
blob
|
history
diff --git
a/perl/schedproc
b/perl/schedproc
index f06a7783d32d14db7c531adeebd1286c87bb5b04..dab1f18a49ed29ac911e6973079d47ad61e68bd9 100755
(executable)
--- a/
perl/schedproc
+++ b/
perl/schedproc
@@
-48,7
+48,7
@@
die "Invalid arguments\n" unless
GetOptions(\%opts, 'schedule=s', 'grades=s', 'name=s', 'format|f=s', 'config|F=s', 'out|o=s');
if (-r $opts{'config'}) {
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/^([^=]*)=(.*)/;
while(<CONFIG>) {
s/\#.*//;
next unless m/^([^=]*)=(.*)/;
@@
-180,7
+180,7
@@
sub get_grades {
sub get_faculty_email {
my ($name, $school, $email);
if((-f $ENV{'HOME'} . "/public_html/faculty.csv") && ! %faculty) {
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/"([^"]*)",([^,]*),([^,]*)/; # "
while($_ = <INS>) {
chomp;
m/"([^"]*)",([^,]*),([^,]*)/; # "
@@
-268,7
+268,7
@@
sub do_mhc_schedule {
my @lines;
foreach my $name (<$file/[1-9]*>) {
next unless $name =~ /^$file\/[1-9][0-9]*$/;
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) {
@lines = <FH>;
close FH;
foreach (@lines) {
@@
-278,12
+278,12
@@
sub do_mhc_schedule {
my $i=0;
foreach (@mhc) {
while(-f ++$i) {}
my $i=0;
foreach (@mhc) {
while(-f ++$i) {}
- open
FH, ">$file/$i" or
die $!;
+ open
(FH, ">$file/$i") ||
die $!;
print FH $_;
close FH;
}
} else {
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);
}
print "# MHC school schedule\n# Autogenerated by sctweb ".localtime()."\n\n";
print join("\n", @mhc);
}
@@
-295,7
+295,7
@@
sub do_csv_schedule {
my @mon = qw(Jan. Feb. Mar. Apr. May June July Aug. Sept. Oct. Nov. Dec.);
my ($current, @mhc, @schedule);
@schedule = get_schedule(@_);
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'});
foreach my $row (@schedule) {
map {s/\n/-/g if defined; $_} %$row;
my $id=generate_id($row->{'id'});
@@
-320,8
+320,8
@@
sub do_vcalendar_schedule {
my %days = (M => "MO", T => "TU", W => "WE", R => "TH", F => "FR", S => "SA", U => "SU");
my $file = $opts{'out'};
my @schedule = get_schedule(@_);
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;
print "BEGIN:VCALENDAR\r\nVERSION:1.0\r\n";
foreach my $row (@schedule) {
map { s/\n/-/g; $_} %$row;
@@
-369,7
+369,7
@@
sub do_xml_schedule {
my $schedule = { class => [ get_schedule(@_) ] };
my $xml = XMLout($schedule, NoAttr => 1, RootName => 'schedule');
if($file) {
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 {
print FH $xml;
close FH;
} else {
@@
-382,7
+382,7
@@
sub do_html_schedule {
my $shade = "dark";
my @schedule = get_schedule(@_);
if($opts{'out'}) {
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>";
select FH;
}
print '<table id="schedule" cellpadding="3" cellspacing="0">'."\n<tr><th>";
@@
-427,7
+427,7
@@
sub do_html_grades {
my ($row);
my $shade = "dark";
if($opts{'out'}) {
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>";
select FH;
}
print '<table id="grades" cellpadding="3" cellspacing="0">'."\n<tr>";
@@
-475,4
+475,3
@@
if ($opts{'format'} eq "xml") {
} else {
die "Unknown format. Try specifying --format.\n"
}
} else {
die "Unknown format. Try specifying --format.\n"
}
-