in reply to Re: What should be returned in scalar context?
in thread What should be returned in scalar context?

I am not talking a standard that is imposed on the programmer.

I am saying that I as a programmer need to make this choice fairly often, what choices should I tend to make, and why?

As for what to do in void context, my default has always been to treat it like scalar, but some people have already said that they standardizing on having functions mutate the input in place in void context. So yes, thinking through void context as well might make sense. (Though I probably won't because the only suggestion that I have seen runs too far counter to the rest of my personal style.)

  • Comment on Re: Re: What should be returned in scalar context?

Replies are listed 'Best First'.
Re: Re: Re: What should be returned in scalar context?
by duff (Parson) on Dec 02, 2003 at 16:31 UTC
    I am saying that I as a programmer need to make this choice fairly often, what choices should I tend to make, and why?

    You use wantarray that much? I've used it less than a couple of handfuls of times in the 11+ years I've been using perl. Most of the time I write subroutines that return lists, I say that's what they do. Period. It's rare that I need different functionality depending on context. It's only when I think "it sure would be nice if this routine did this sometimes and that other times" that wantarray might come into the picture. And when that happens, I've already decided what I need from scalar, list and void contexts. (I don't usually care about void context though)