Perl Script: Variable Names composed of Variables
Hi,
I am pretty new to perl, and i have just begun writing a small sudoku solver. I am wondering if there is a function which allows you so combine two variables and use them as the name for an other variable. For example: $i=55; $n=12; $i,$n="whatever the variable should contain"; The $i,$n= are supposed to be 5512. Is there any way to do such a thing? Or is there a way to get 3 dimensional matrices or other arrays with more than one dimension? If there are such things, what do they look like?? Thanks!! |
Quote:
Code:
%hash_of_array = ( Code:
%hash_of_hash = ( |
you can't have a comma, in a perl variable name and you can't start with a digit.
You should use bullivers suggestion. However FYI: You can do things like this though: Code:
$ perl Code:
$ perl Also it is a whole world of bugs waiting to happen! |
Thanks for all your help.
I went with bulliver's method. I now am able to store each possible value in a list, which of each field corresponds to a list of possibilities. Bigbearsbilly, you are right - it works, but it's only bugs waiting to happen. I am probably not going to use this method, even thoug it looks interesting. |
You can do it with funcs. Can be very useful.
E.g. I was writing a server and wanted a list of valid commands and help text for each but also it's easy to lose track. So I did: Code:
@command_list = sort qw( DUMMY DUMP ADD DEL WHO DROP LOAD COUNT QUIT HELP ); |
All times are GMT -5. The time now is 01:14 PM. |