Paul Johnson wrote: > R. Joseph Newton said: > > > The only thing it > > lacked was a meaningful return value. Since the getTarget function > > provided enough information to decide in favor of an early exit, this > > information should probably be passed on more explicitly, perhaps just by > > returning 0 rather than undef. > > Just to pick nits, I think that a plain return here is absolutely correct. > Or, at least it is in the general case, given that we know nothing about > the return values of this particular function. > > The reason? If you return 0 or an explicit undef, and then call the > function in list context, you will have returned a true value, a list with > one element. If you just return, then in list context the return value > will be an empty list, which is a false value. Calling a function in list > context can occur more often that you might imagine, and so I recommend > this as a good habit to get into. > > -- > Paul Johnson - [EMAIL PROTECTED]
Good point, Paul. I forget that Perl has that feature. I mean, I use it to load variables from existing functions, but I seriously doubt that I would ever return anything other than scalar from a function. I value the funnel model for functions. I tend to use reference parameters for any function whose specification would not be satisfied with a discrete scalar. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]