diff --git a/meta/recipes-devtools/perl/perl_5.40.2.bb b/meta/recipes-devtools/perl/perl_5.40.2.bb
index a78d2ed0be..19de35fdc7 100644
--- a/meta/recipes-devtools/perl/perl_5.40.2.bb
+++ b/meta/recipes-devtools/perl/perl_5.40.2.bb
@@ -57,7 +57,13 @@ CFLAGS:append:toolchain-clang = " -fno-strict-aliasing"
 # Needed with -march=x86-64-v3
 CFLAGS:append:toolchain-gcc:class-target:x86-64 = " -fno-builtin-memcpy -D__NO_STRING_INLINES -U_FORTIFY_SOURCE"
 
+# ${B} will have been set as our current directory immediately before
+# do_configure is called. So let's avoid any problems associated
+# with it being deleted from underneath us by moving to somewhere else.
+# We're being put back there (the new version) at the end of this code
+#
 do_configure:prepend() {
+    cd ${WORKDIR}
     rm -rf ${B}
     cp -rfp ${S} ${B}
     cp -rfp ${STAGING_DATADIR_NATIVE}/perl-cross/* ${B}
