Fix some issues near recent chomp changes.

Reviewed-by: Richard Levitte <levitte@openssl.org>
diff --git a/apps/CA.pl.in b/apps/CA.pl.in
index fbba457..f5e8e4a 100644
--- a/apps/CA.pl.in
+++ b/apps/CA.pl.in
@@ -120,9 +120,9 @@
     close OUT;
     # ask user for existing CA certificate
     print "CA certificate filename (or enter to create)\n";
-    $FILE = <STDIN>;
-    $FILE = s|\R$|| if $FILE;
-    if ($FILE) {
+    $FILE = "" unless defined($FILE = <STDIN>);
+    $FILE =~ s{\R$}{};
+    if ($FILE ne "") {
         copy_pemfile($FILE,"${CATOP}/private/$CAKEY", "PRIVATE");
         copy_pemfile($FILE,"${CATOP}/$CACERT", "CERTIFICATE");
     } else {
diff --git a/crypto/perlasm/x86_64-xlate.pl b/crypto/perlasm/x86_64-xlate.pl
index a0b3bc0..0a023fb 100755
--- a/crypto/perlasm/x86_64-xlate.pl
+++ b/crypto/perlasm/x86_64-xlate.pl
@@ -850,7 +850,7 @@
 OPTION	DOTNAME
 ___
 }
-while($line=<>) {
+while(defined($line=<>)) {
 
     $line =~ s|\R$||;           # Better chomp
 
diff --git a/util/files.pl b/util/files.pl
index d984196..32e7125 100755
--- a/util/files.pl
+++ b/util/files.pl
@@ -25,8 +25,8 @@
 				{
 				$b=$`; # Keep what is before the backslash
 				$o.=$b." ";
-				$b=<>;
-				$b =~ s|\R$||; # Better chomp
+				$b = "" unless defined($b = <>);
+				$b =~ s{\R$}{};
 				}
 			else
 				{
@@ -43,7 +43,7 @@
 		}
 	}
 
-$pwd=`pwd`; $pwd =~ s|\R$||;
+($pwd=`pwd`) =~ s{\R$}{};
 
 if ($sym{'TOP'} eq ".")
 	{
diff --git a/util/mk1mf.pl b/util/mk1mf.pl
index 3a9f0d7..f29e50b 100755
--- a/util/mk1mf.pl
+++ b/util/mk1mf.pl
@@ -553,8 +553,10 @@
 			{
 			open (IN, "util/fipslib_path.txt") || fipslib_error();
 			$fipslibdir = <IN>;
-			$fipslibdir =~ s|\R$||;
 			close IN;
+			$fipslibdir = "" unless defined($fipslibdir);
+			$fipslibdir =~ s{\R$}{};
+			fipslib_error() if ($fipslibdir eq "");
 			}
 		fips_check_files($fipslibdir,
 				"fipscanister.lib", "fipscanister.lib.sha1",
diff --git a/util/mkfiles.pl b/util/mkfiles.pl
index 4fbe29a..55dfbc6 100755
--- a/util/mkfiles.pl
+++ b/util/mkfiles.pl
@@ -107,8 +107,8 @@
 				{
 				$b=$`;
 				$o.=$b." ";
-				$b=<IN>;
-				$b =~ s|\R$||;
+				$b = "" unless defined($b = <IN>);
+				$b =~ s{\R$}{};
 				}
 			else
 				{