in reply to lazily getting around an Exporter problem
Unless you really need the lazy evaluation, memoization, and what-not, you could use Want directly. Want is the module that Contextual::Return uses to figure out the context. Here's an example:
use Want; sub funner { if (want('LIST')) { return qw/Larry Curly Moe/; } elsif (want('ARRAY')) { return [ qw/Larry Curly Moe/ ]; } else { croak("listy type contexts only"); } } print Dumper [ funner() ]; print Dumper [ @{funner()} ]; funner(); __END__ $VAR1 = [ 'Larry', 'Curly', 'Moe' ]; $VAR1 = [ 'Larry', 'Curly', 'Moe' ]; listy type contexts only at ...
lodin
|
|---|