in reply to getting args without clobbering @ARGV

could be this?
perl -e 'for(0..$#ARGV){($debug,$infile)=(1,$ARGV[$_+1]) if $ARGV[$_]= +~/-d/}'