in reply to List Processing Functions and Wantarray

Perhaps you could start with some guesses?

sub localtime { my $time = shift || time; # code to convert to @time_parts if (wantarray) { return @time_parts; } elsif (defined wantarray) { return sprintf("...",@time_parts); } }

In this example, localtime is aware of whether you want an array (in which case it returns all the pieces so you can do what you want with it), or you want a scalar (in which case it prints it in human-readable format to a string, and returns that), or you don't want anything (wantarray returns undef - so it doesn't return anything).