sub Dump { no strict 'refs'; my $implementation = __PACKAGE__->implementation; my $debug; # My own debug variable for my $option (@dump_options) { my $var = "$implementation\::$option"; $debug = $var if $var =~/UseCode/; #the option I wish to set my $value = $$var; local $$var; # <-- PROBLEM! Local to "for", not "sub" $$var = defined $value ? $value : ${"YAML::$option"}; # Here I print out the option in each iteration of the loop print STDERR "$debug = $$debug\n"; } # And the final value: print STDERR "FINAL: $debug = $$debug\n"; return &{"$implementation\::Dump"}(@_); }