in reply to Re^2: How to combine these 2 subroutines in one?
in thread How to combine these 2 subroutines in one?
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, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to combine these 2 subroutines in one?
by Anonymous Monk on Apr 03, 2014 at 14:19 UTC | |
by Anonymous Monk on Apr 03, 2014 at 23:13 UTC | |
by Athanasius (Archbishop) on Apr 04, 2014 at 08:55 UTC | |
by Anonymous Monk on Apr 04, 2014 at 09:14 UTC | |
by Athanasius (Archbishop) on Apr 04, 2014 at 09:36 UTC | |
|