in reply to Bug in YAML::Any - What to do?
sub Dump { my @opts; for my $option (@dump_options) { no strict 'refs'; my $ref = \${$implementation.'::'.$option}; push @opts, [ $ref => defined($$ref) ? $$ref : ${"YAML::$option"}, ]; } local ${$_->[0]} = $_->[1] for @opts; return &{"$implementation\::Dump"}; }
Sticking to something that won't break:
{ package YAML::OnScopeExit; sub DESTROY { ${ shift() }->() } } sub _on_scope_exit(&) { my ($sub) = @_; return bless(\$sub, 'YAML::OnScopeExit'); } sub Dump { my @opts; for my $option (@dump_options) { no strict 'refs'; my $ref = \${$implementation.'::'.$option}; push @opts, [ $ref => defined($$ref) ? $$ref : ${"YAML::$option"}, $$ref, ]; } my $sentinel = _on_scope_exit { ${$_->[0]} = $_->[2] for @opts; }; ${$_->[0]} = $_->[1] for @opts; return &{"$implementation\::Dump"}; }
Both untested.
|
|---|