use The::Package; # sub my_generator(&) is exported by The::Package my $complex_result = my_generator { foo 'bar'; takes_coderef { ... }; }; foo 'baz'; # Should not affect $complex_result. # Ideally, should croak, or not even compile.