in reply to Variable from a variable: the dark side?
So, my questions: (1) how do I build this variable $type.$t and (2) is there a better way?
The usual response when someone wants to do this is (and it applies equally here) use a hash.
$t = $q->param('type'); $type{$t} = 1;
That said, if you *really* want to create variables "the evil way", it's done like this:
${"type" . $type} = 1;If $type = 5, then this will create a variable called $type5 and give it a value of 1. Caveat lector!
|
|---|