gwhite has asked for the wisdom of the Perl Monks concerning the following question:
Going through some code someone else wrote and found this and I don't understand it. Can someone shed some light?
#this creates a new $config thing my $config = new ConfigReader::Simple($config_file); #this checks for a true in one of the elements of the $config if ($config->adv_conf){ ... } #this creates an array out of a list of words my @batch_list = split /\s+/, $config->batch_list; #the next line puts a reference to the array into the $config #but why the $$ and no -> $$config{batch_list} = \@batch_list; #could it be done just as easily with this $config->set(batch_list, \@batch_list); #I am thinking probably not since the doc says: #set( DIRECTIVE, VALUE ) #Sets the value for DIRECTIVE to VALUE. The DIRECTIVE need not already + exist. This overwrites previous values. #The VALUE must be a simple scalar. It cannot be a reference. If the V +ALUE is a reference, the function prints a warning and returns false.
and what are the proper ways to access that $config element?
my @list = @{$$config{batch_list}};
my @list = @{$config->batch_list};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: module reference is used in a confusing way
by kennethk (Abbot) on Nov 07, 2008 at 19:41 UTC |