From fe99a1ee0030079ffbfaf9b00280b549466f4083 Mon Sep 17 00:00:00 2001
From: brian d foy <briandfoy@pobox.com>
Date: Wed, 7 Dec 2022 18:29:10 -0500
Subject: [PATCH] GitHub #131 - CPAN_OPTS ends upon the wrong side of the args

Co-authored-by: chirvasitua <stuart-little@users.noreply.github.com>
---
 lib/App/Cpan.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/App/Cpan.pm b/lib/App/Cpan.pm
index 6358e82a..5577161c 100644
--- a/lib/App/Cpan.pm
+++ b/lib/App/Cpan.pm
@@ -264,7 +264,8 @@ to C<1> unless it already has a value (even if that value is false).
 =item CPAN_OPTS
 
 As with C<PERL5OPT>, a string of additional C<cpan(1)> options to
-add to those you specify on the command line.
+add to those you specify on the command line. This string is split
+on whitespace and each element added to the front of the argument list.
 
 =item CPANSCRIPT_LOGLEVEL
 
@@ -410,7 +411,7 @@ sub _process_options
 	{
 	my %options;
 
-	push @ARGV, grep $_, split /\s+/, $ENV{CPAN_OPTS} || '';
+	unshift @ARGV, grep $_, split /\s+/, $ENV{CPAN_OPTS} || '';
 
 	# if no arguments, just drop into the shell
 	if( 0 == @ARGV ) { CPAN::shell(); exit 0 }