---
 configure          | 21 +++++++++++++++++----
 local/Makefile.in  | 20 ++++++++++----------
 net-snmp-config.in |  2 +-
 3 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/configure b/configure
index 907d441..ede38ec 100755
--- a/configure
+++ b/configure
@@ -30633,6 +30633,10 @@ if test "x$embed_perl" = "xtry" ; then
     fi
 fi
 
+if test "x$embed_perl" = "xyes" ; then
+    myperl=$ac_cv_path_PERLPROG
+fi
+
 #       Perl modules require the perl binary
 #
 if test "x$install_perl" != "xno" ; then
@@ -30681,7 +30685,7 @@ fi
 #   The rest of the Perl-related checks aren't relevant
 #       if we're not using the Perl modules
 #
-if test "x$install_perl" != "xno" ; then
+if test "x$embed_perl" != "xno" ; then
 
 
 ##
@@ -30690,7 +30694,7 @@ if test "x$install_perl" != "xno" ; then
 
     #       What compiler was used to build the perl binary?
     #
-    if test "x$enable_perl_cc_checks" != "xno" ; then
+    if test "x$embed_perl" != "xno" ; then
         { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Perl cc" >&5
 printf %s "checking for Perl cc... " >&6; }
 
@@ -30754,7 +30758,7 @@ printf "%s\n" "$perlcc_is_gnu" >&6; }
 
 	#       Check compatability:  Non-Gnu Net-SNMP vs Gnu perl
 	#
-	if test "x$install_perl" != "xno" ; then
+	if test "x$embed_perl" != "xno" ; then
 	    if test "x$GCC" != "xyes" -a "x$perlcc_is_gnu" = "xyes" ; then
 		    if test "x$install_perl" = "xtry" ; then
 			install_perl="no"
@@ -30772,7 +30776,6 @@ printf "%s\n" "$perlcc_is_gnu" >&6; }
     else
         if test "x$install_perl" = "xno" ; then
             install_perl="no"
-            embed_perl="no"
         fi
     fi
 
@@ -30824,6 +30827,11 @@ if test "x$embed_perl" != "xno" ; then
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Perl CFLAGS" >&5
 printf %s "checking for Perl CFLAGS... " >&6; }
     perlcflags=`$myperl -MExtUtils::Embed -e ccopts`
+    if [ -n "$PERLCFLAGS" ]; then
+      perlcflags="$PERLCFLAGS"
+    else
+      perlcflags=`$myperl -MExtUtils::Embed -e ccopts`
+    fi
     if test "x$perlcflags" != "x" ; then
       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $perlcflags" >&5
 printf "%s\n" "$perlcflags" >&6; }
@@ -30843,6 +30851,11 @@ if test "x$embed_perl" != "xno" ; then
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Perl LDFLAGS" >&5
 printf %s "checking for Perl LDFLAGS... " >&6; }
     netsnmp_perlldopts=`$myperl -MExtUtils::Embed -e ldopts`
+    if [ -n "$PERLLDFLAGS" ]; then
+      netsnmp_perlldopts="$PERLLDFLAGS"
+    else
+      netsnmp_perlldopts=`$myperl -MExtUtils::Embed -e ldopts`
+    fi    
     if test "x$netsnmp_perlldopts" != "x" ; then
       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $netsnmp_perlldopts" >&5
 printf "%s\n" "$netsnmp_perlldopts" >&6; }
diff --git a/local/Makefile.in b/local/Makefile.in
index db8cfda..622e063 100644
--- a/local/Makefile.in
+++ b/local/Makefile.in
@@ -87,28 +87,28 @@ snmpcheck: $(srcdir)/snmpcheck.def ../sedscript
 
 snmpcheck.made: snmpcheck
 	if test "x$(PERL)" != "x" ; then \
-	  $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%' snmpcheck > snmpcheck.made ; \
+	  $(PERL) -p -e '' snmpcheck > snmpcheck.made ; \
 	else \
 	  touch snmpcheck.made ; \
         fi
 
 tkmib.made: $(srcdir)/tkmib
 	if test "x$(PERL)" != "x" ; then \
-	  $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%' ${srcdir}/tkmib > tkmib.made; \
+	  $(PERL) -p -e '' ${srcdir}/tkmib > tkmib.made; \
 	else \
 	  touch tkmib.made; \
         fi
 
 mib2c.made: $(srcdir)/mib2c
 	if test "x$(PERL)" != "x" ; then \
-	  $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%;s#/usr/local/share/snmp#$(snmplibdir)#;' ${srcdir}/mib2c > mib2c.made; \
+	  $(PERL) -p -e '' ${srcdir}/mib2c > mib2c.made; \
 	else \
 	  touch mib2c.made; \
         fi
 
 net-snmp-cert.made: $(srcdir)/net-snmp-cert
 	if test "x$(PERL)" != "x" ; then \
-	  $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%;s#/usr/local/share/snmp#$(snmplibdir)#;' ${srcdir}/net-snmp-cert > net-snmp-cert.made; \
+	  $(PERL) -p -e '' ${srcdir}/net-snmp-cert > net-snmp-cert.made; \
 	else \
 	  touch net-snmp-cert.made; \
         fi
@@ -116,42 +116,42 @@ net-snmp-cert.made: $(srcdir)/net-snmp-cert
 
 ipf-mod.pl.made: $(srcdir)/ipf-mod.pl
 	if test "x$(PERL)" != "x" ; then \
-	  $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%' ${srcdir}/ipf-mod.pl > ipf-mod.pl.made; \
+	  $(PERL) -p -e '' ${srcdir}/ipf-mod.pl > ipf-mod.pl.made; \
 	else \
 	  touch ipf-mod.pl.made; \
         fi
 
 fixproc.made: $(srcdir)/fixproc
 	if test "x$(PERL)" != "x" ; then \
-	  $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%' ${srcdir}/fixproc > fixproc.made; \
+	  $(PERL) -p -e '' ${srcdir}/fixproc > fixproc.made; \
 	else \
 	  touch fixproc.made; \
         fi
 
 snmpconf.made: snmpconf
 	if test "x$(PERL)" != "x" ; then \
-	  $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%; s#/usr/local/share#$(datadir)#g; s#/usr/local/etc/snmp#$(SNMPCONFPATH)#g; s#/var/net-snmp#$(PERSISTENT_DIRECTORY)#g' snmpconf > snmpconf.made; \
+	  $(PERL) -p -e 's#/usr/local/share#$(datadir)#g; s#/usr/local/etc/snmp#$(SNMPCONFPATH)#g; s#/var/net-snmp#$(PERSISTENT_DIRECTORY)#g' snmpconf > snmpconf.made; \
 	else \
 	  touch snmpconf.made; \
         fi
 
 traptoemail.made: $(srcdir)/traptoemail
 	if test "x$(PERL)" != "x" ; then \
-	  $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%; s#/usr/local/share#$(datadir)#g; s#/usr/local/etc/snmp#$(TRAPTOEMAILPATH)#g' ${srcdir}/traptoemail > traptoemail.made; \
+	  $(PERL) -p -e 's#/usr/local/share#$(datadir)#g; s#/usr/local/etc/snmp#$(TRAPTOEMAILPATH)#g' ${srcdir}/traptoemail > traptoemail.made; \
 	else \
 	  touch traptoemail.made; \
         fi
 
 snmp-bridge-mib.made: $(srcdir)/snmp-bridge-mib
 	if test "x$(PERL)" != "x" ; then \
-	  $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%' ${srcdir}/snmp-bridge-mib > snmp-bridge-mib.made; \
+	  $(PERL) -p -e '' ${srcdir}/snmp-bridge-mib > snmp-bridge-mib.made; \
 	else \
 	  touch snmp-bridge-mib.made; \
         fi
 
 checkbandwidth.made: $(srcdir)/checkbandwidth
 	if test "x$(PERL)" != "x" ; then \
-	  $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%' $(srcdir)/checkbandwidth > checkbandwidth.made ; \
+	  $(PERL) -p -e '' checkbandwidth > checkbandwidth.made ; \
 	else \
 	  touch checkbandwidth.made ; \
 	fi
diff --git a/net-snmp-config.in b/net-snmp-config.in
index c0fc154..ce1e16f 100644
--- a/net-snmp-config.in
+++ b/net-snmp-config.in
@@ -139,7 +139,7 @@ else
       echo @PERSISTENT_DIRECTORY@
       ;;
     --perlprog|--perl)
-      echo @PERLPROG@
+      echo perl
       ;;
     #################################################### compile
     --base-cflags)
-- 
2.34.1

