in reply to Returning first element of an array from a function
If you're writing your own function, you can use the wantarray function to tell if the function has been called in an array or scalar context:$val=(split(/\./,$bar))[0];
sub flexible { .... if (wantarray) { return @arr; } else { return $scal; } }
|
|---|