|laziness, impatience, and hubris|
Re^3: Context aware functions - best practices?by LAI (Hermit)
|on Jan 14, 2003 at 21:50 UTC||Need Help??|
You are aware thatwill evaluate to the number of elements returned by foo rather than return the last one of them, right? :)
Yes, of course. I wrote that in reference to my $x = foo(1); setting $x to 1 :oP
I agree that it would be a rare case when the flattened array would be an acceptable return value, but I still don't like the idea of throwing away data. Oh, well. The only alternative I can think of is the hideous
which borders on the obfuscated. I wouldn't use something like that if I were you. Of course I'm me, and love using lines like that, but I digress...
Zaxo's suggestion of using $arr[-1] makes sense too, especially if the sub is doing something cumulative with its args. Imagine a sum() function that keeps track of all the intermediate sums, or whatever.