in reply to scope of variables in a sub

sub make_ap_stanza () { my $policy = $_[0];

So, you declare the subroutine with empty prototypes, i.e. as taking no parameters, but then you extract the first parameter.

See Understand why you probably don’t need prototypes.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]