use Test::More; package Foo { sub new { bless { }, shift }; sub method { my ($self, $arg) = @_; # Network operation followed by internal processing, but # for the sake of example, say we've already done all # that and it's in $arg. (Normally method takes no args, # and is non-idempotent): wantarray ? (_special_to_string($arg), $arg) : _special_to_string($arg); } sub _special_to_string { # Really requires 100-odd lines of transformation code, # split among several other internal subs, but for now: lc(shift); } } my $arg = 'Really Special'; my $foo = Foo->new; is scalar $foo->method($arg), lc($arg), 'explicit scalar context'; my $string = $foo->method($arg); is $string, lc($arg), 'scalar assignment'; my ($plain, $special) = $foo->method($arg); is_deeply [ $foo->method($arg) ], [ lc($arg), $arg ], 'list'; __END__ ok 1 - explicit scalar context ok 2 - scalar assignment ok 3 - list