Просмотр исходного кода

Warn rather than dying if open() fails

Zachary Kotlarek 13 лет назад
Родитель
Сommit
73d0a8325b
1 измененных файлов с 8 добавлено и 7 удалено
  1. 8 7
      dmx/state.pl

+ 8 - 7
dmx/state.pl

@@ -178,14 +178,15 @@ while (1) {
 
 		# Grab the state from STATUS files
 		if ($file->{'type'} =~ /^STATUS/) {
-			my $text = undef();
+			my $text = '';
 			{
-				my $fh;
-				open($fh, $file->{'path'})
-				  or die('Unable to open ' . $file->{'path'} . "\n");
-				local $/;
-				$text = <$fh>;
-				close($fh);
+				if (!open(my $fh, $file->{'path'})) {
+					warn('Unable to open ' . $file->{'path'} . "\n");
+				} else {
+					local $/;
+					$text = <$fh>;
+					close($fh);
+				}
 			}
 
 			if ($file->{'type'} eq 'STATUS_PLAYING') {