in reply to getting args without clobbering @ARGV
perl -e 'for(0..$#ARGV){($debug,$infile)=(1,$ARGV[$_+1]) if $ARGV[$_]= +~/-d/}' [download]