How do I use symbolic references in Perl?

后端 未结 7 1574
栀梦
栀梦 2020-12-02 02:02

In Perl, if a variable holds the name for another variable, how do I use the first variable to visit the other one?

For example, let

$name = \"bob\";         


        
7条回答
  •  死守一世寂寞
    2020-12-02 03:05

    See perldoc -q "variable name":

    Beginners often think they want to have a variable contain the name of a variable. ...

    Short answer: Don't. Long answer: Read the FAQ entry (which is also available on your computer). Longer answer: Read MJD's Why it's stupid to "use a variable as a variable name" (Part 2, Part 3).

提交回复
热议问题