in reply to Returning first element of an array from a function

If you're using someone else's function, and only want the first element, you can do something like this:
$val=(split(/\./,$bar))[0];
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:
sub flexible { .... if (wantarray) { return @arr; } else { return $scal; } }