<p>In PHP, I can write:</p>

<pre><code>$vname = 'phone';
$$vname = '555-1234';
print $phone;
</code></pre>

<p>... And the script will output "555-1234".</p>

<p>Is there any equivalent in Perl?</p>

<p>Is there any way to constrain <code>$phone</code> to the scope of the local block, as if I'd written <code>my $phone</code>? Using <code>my $$vname</code> gives me "Can't declare scalar dereference in my at ..." errors.</p>

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!