diff --git a/aclocal.m4 b/aclocal.m4
index de6b4215fa25426ba513f866ea3bb870bfd81171..0e3d91cd4c4728c72732e497a12ad29140b9f6a1 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -273,8 +273,8 @@ AC_DEFUN(AC_PROG_GNUCPP,
 [if test "$HaveGcc" = "YES"; then
 	echo > conftest.c
 	gcc -v -E conftest.c >/dev/null 2>conftest.out
-	echo '/(\S+(\/|\\)cpp)/ && print "[$]1";' > conftest.pl
-	ac_cv_gnu_cpp="`eval $PerlCmd -n conftest.pl conftest.out | tr '\\\' / `"
+	echo '/(\S+(\/|\\)cpp)/ && ([$]foo = [$]1) =~ tr/\\/\// && print "[$]foo";' > conftest.pl
+	ac_cv_gnu_cpp="`eval $PerlCmd -n conftest.pl conftest.out`"
 	rm -fr conftest*
  else
 	# We need to be able to invoke CPP directly, preferably