in reply to Distinguishing between an array of objects and an array of strings
ref is true if its operand is a reference so you can test like this:
use warnings; use strict; my $str = 'Str'; my $rStr = \$str; my $rrStr = \$rStr; print "\$rrStr is ref to ref to str\n" if ref $rrStr and ref $$rrStr; print "\$rStr is ref to str\n" if ref $rStr; print "\$str is str\n" if ! ref $str;
Note that each additional $ dereferences by one.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Distinguishing between an array of objects and an array of strings
by tinita (Parson) on Sep 22, 2005 at 10:30 UTC | |
by Zaxo (Archbishop) on Sep 22, 2005 at 11:49 UTC | |
by Anonymous Monk on Sep 22, 2005 at 12:41 UTC | |
by diotalevi (Canon) on Sep 22, 2005 at 14:31 UTC | |
by friedo (Prior) on Sep 22, 2005 at 14:29 UTC | |
by Anonymous Monk on Sep 22, 2005 at 10:45 UTC |