Therefore one idea that strikes me is to manually set the contents of $ARGV[n] at the top of the source before any other code is run. Would this approach work?
Sure, that's fine, just make sure to only set it when you're running under the debugger, so as to not override any command line options later set by the user. There isn't really anything that magical about @ARGV, most functions and modules only read it at runtime, and you can write to it whenever you like. If in theory you had a module that accessed @ARGV when you use it, you'd need to set it in a BEGIN block before you use that module, but I haven't come across a module that does this yet.
use Data::Dump;
use Getopt::Long;
@ARGV = qw/ --foo --bar=123 --quz=Hello /;
GetOptions(\my %OPTS1, 'foo|f', 'bar|b=i', 'quz|q=s') or die;
dd \%OPTS1;
@ARGV = qw/ -q World /;
GetOptions(\my %OPTS2, 'foo|f', 'bar|b=i', 'quz|q=s') or die;
dd \%OPTS2;
__END__
{ bar => 123, foo => 1, quz => "Hello" }
{ quz => "World" }
|