Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Apr 152010

How to find out whether reference is pointing to a scalar, array or hash in Perl?


Use the ref() function

my $data = [1,2,3];
print ref($data); # print out ARRAY

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>