Each
use statement is executed at the moment it's been parsed. The same applies to a BEGIN block.
my has two parts - the declaration of the variable happens immediately at compile time, the assignment happens later at run time. Therefore, in the first case, the dumping happens before the BEGIN block has been fully parsed, which means its (the BEGIN block's) code hasn't been run yet.
To make the variable lexical, specify
my %vars;
before the BEGIN block.
Update: You probably wanted something like
{ my %vars;
BEGIN {
$vars{k} = 'v';
}
use Acme::PERLANCAR::DumpImportArgs %vars;
}
Update 2: Explanation of two parts of my.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]