1.4 Querying a ReferenceThe ref function queries a scalar to see whether it contains a reference and, if so, what type of data it is pointing to. ref returns false (a Boolean value, not a string) if its argument contains a number or a string; and if it's a reference, ref returns one of these strings to describe the data being referred to: "SCALAR", "HASH", "ARRAY", "REF" (referring to another reference variable), "GLOB" (referring to a typeglob), "CODE" (referring to a subroutine), or " package name " (an object belonging to this package - we'll see more of it later). $a = 10; $ra = \$a; ref($a) yields FALSE, since $a is not a reference. ref($ra) returns the string "SCALAR", since $ra is pointing to a scalar value. Copyright © 2001 O'Reilly & Associates. All rights reserved. |
|