- # I'd like to use *{ $self->[0] } = $self->[1]->(); here,
- # but that causes all sorts of problems. The hash is accessible from
- # within this sub, but not where its creation was triggered.
- # Immediately after the triggering statement, the hash becomes available
- # to all: even the scope where the previous access attempt failed.
-
- %{ $self->[0] } = %{ $self->[1]->() }
+ if ($] >= 5.018) {
+ my $code = delete $self->[1] or return;
+ $self->[0] = $code->();
+ return 1;
+ }
+
+ untie %{ $self->[0] };
+ %{ $self->[0] } = %{ $self->[1]->() }; # *{ $self->[0] } = $self->[1]->();
+ return;