in reply to most appropriate return data type

There's generally nothing wrong with doing it that way (as long as you document your API clearly).

Note that there's also wantarray, which you could use additionally to return different things depending on the calling context:

#!/usr/bin/perl -l sub test { return wantarray ? @_ : $_[0]; } my @arr = test(1); print "@arr"; @arr = test(1,2,3); print "@arr"; my $scalar = test(1,2,3); print $scalar; __END__ 1 1 2 3 1