in reply to data type discovery inside sub: how?

You are close. When you determine that you were passed an array reference, you need to copy the array, not the reference. Instead of:

if ($varType eq "ARRAY") { my @tmp = $_[0];

you need to dereference the reference:

if ($varType eq "ARRAY") { my @tmp = @{ $_[0] };

Also see tye's References Quick Reference for a quick overview of references in Perl