Does Perl have PHP-like dynamic variables?

前端 未结 5 1651
北恋
北恋 2020-12-03 06:16

In PHP, I can write:

$vname = \'phone\';
$$vname = \'555-1234\';
print $phone;

... And the script will output \"555-1234\".

Is ther

5条回答
  •  情歌与酒
    2020-12-03 06:25

    You can do it in a very similar way:

    $vname = "phone";
    $$vname = "555-1234";
    print $phone;
    

    But that you can doesn't mean that you should. The best way to manage this is, as Michael Carman says, USE A HASH!

提交回复
热议问题