Two obvious problems (there may be others):
@_ is the array of arguments passed into the subroutine, so \@_ will always be an array reference. You need ref($_[0]) which tests the first argument (but see my answer above as to why this may not be the best approach).
If the array is passed in as a reference, $type_of_arg will be the string 'ARRAY', indicating an array reference. If the array is passed in as a list (and if the first element of that list doesn’t happen to be a reference), $type_of_arg will be the empty string, not 'REF'. Again, see ref.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re^3: How to combine these 2 subroutines in one?
by Athanasius
in thread How to combine these 2 subroutines in one?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |