You should probably use a hash to store your data. In a hash you decide the 'names' (i.e. the keys) to your data.
Update: You may also want to follow this thread to read more about it.
"Livet är hårt" sa bonden.
"Grymt" sa grisen...
| [reply] |
It's possible, but you don't want to. Instead, you want to use a hash. You can think of the elements in the hash as if they're variables on their own.
$foo = 'bar';
$hash{$foo} = "Hello, World!\n";
print $hash{bar}; # prints Hello, World! and a linefeed
(Note: Variables are put in a hash themselves (%package:: (or just %::)), You could use ${$foo} = "Hello, World!\n" (maybe ${package::}{foo} and $::{foo} can help understanding this) and then print $bar, but it's ugly. Fortunately, use strict prevents you from doing so (unless you use no strict 'refs'))
2;0 juerd@ouranos:~$ perl -e'undef christmas'
Segmentation fault
2;139 juerd@ouranos:~$
| [reply] [d/l] [select] |