How do I tell what type of value is in a Perl variable?

前端 未结 5 2133
旧时难觅i
旧时难觅i 2020-12-02 16:52

How do I tell what type of value is in a Perl variable?

$x might be a scalar, a ref to an array or a ref to a hash (or maybe other things).

5条回答
  •  盖世英雄少女心
    2020-12-02 17:00

    ref():

    Perl provides the ref() function so that you can check the reference type before dereferencing a reference...

    By using the ref() function you can protect program code that dereferences variables from producing errors when the wrong type of reference is used...

提交回复
热议问题