How to get the type of the reference?

Is there any function available in Perl to check the reference type:

my $ref=\@array;

I need to get the reference type as array by the function.

Answers


Use function ref:

$ref_type = ref $ref;

The return value is the one of: SCALAR, ARRAY, HASH, CODE (reference to subprogram), GLOB (reference to typeglob) and REF (reference to reference).

Actually, ref function may return more values and in case of reference to object returns package name instead of type: http://perldoc.perl.org/functions/ref.html.


Need Your Help

JS: How to get the element clicked on?

javascript jquery

How would you check to see which item was clicked in the document, given this code?