in reply to Re^5: How to combine these 2 subroutines in one?
in thread How to combine these 2 subroutines in one?
The syntax @{ $_[0] } says: read the first argument passed into the sub clean_list, and then, treating it as a reference, dereference it to get an array. If this argument isn’t an array reference (as it probably won’t be if you passed in a list when calling the sub), then of course you’ll get an error message to that effect!
Just test the first element, that is, call ref( $_[0] ) — and don’t try to dereference it until you’re sure it’s a reference, which is the whole point of testing it by calling ref.
(I think maybe you should study perlreftut, then perllol, perldsc, and perlref, until you’re comfortable with references in Perl.)
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: How to combine these 2 subroutines in one?
by Anonymous Monk on Apr 04, 2014 at 09:14 UTC | |
by Athanasius (Archbishop) on Apr 04, 2014 at 09:36 UTC | |
by Anonymous Monk on Apr 04, 2014 at 09:41 UTC |