http://qs1969.pair.com?node_id=175359


in reply to struggling with sub-routines

The problem you're seeing has to do with the return call; what it does is just that -- returns the value AND stops execution of the subroutine. So, where your sub has:

return $first; return $second; return $third; return $forth; return $others;
The only value returned is $first; the rest of those are ignored. What you apparently want to do is return a list, and fortunately, that's easy to do:
return ($first, $second, $third, $forth, $others);

or, better yet, since your names clearly suggest an *array*, why not return an array and avoid declaring so many variables?

Your code has a number of other issues (e.g. you pass in a scalar, and yet your subroutine is built to deal with an array, you don't use the return value of your subroutine at all), but I'll just stop here and let others help you out with those issues.

hth

I mistrust all systematizers and avoid them. The will to a system shows a lack of integrity -- F. Nietzsche