ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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??
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 );
foreach my $c (@command_list) {
unless (defined &$c) {
warn "WARNING:command $c not defined!" ;
*$c = sub { print OUT "?function $c?:not defined" };
}
so you get a dummy command defined with a warning.
Last edited by bigearsbilly; 02-06-2006 at 08:46 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.