Confused on hash references

2003-02-13 Thread Barry Kingsbury
I have created the following data structure:

%mailings = ( tv => { mail_demo_key   => "Demo License Key for TotalView",
 mail_thank_you  => "Thank you for downloading 
TotalView",
 pdf => LOCATION_OF_PDF,
 location=> LOCATION_OF_DEMO_REPLY,
 text=> LOCATION_OF_INSTRUCT,
 text_brochure   => LOCATION_OF_BROCHURE },
 cr => { mail_demo_key  => "Demo License Key for JNI Bridge 
and TotalView",
 mail_thank_you => "Thank you for downloading the 
CodeRoad JNI Bridge",
 pdf=> LOCATION_OF_CR_PDF,
 location   => LOCATION_OF_CR_DEMO_REPLY,
 text   => LOCATION_OF_CR_INSTRUCT,
 text_brochure  => LOCATION_OF_CR_BROCHURE }
   );

In other words, the elements of the mailings hash are a key and a 
reference to an unnamed hash. After a lot of playing around, I was able 
to print the elements of the hash as follows:


 $form_name = "tv";
 foreach $key (keys %{$mailings{$form_name}})
 {
 print "$key => " . %{$mailings{$form_name}}->{$key} . "\n";
 }


Also, the following also works:

 $form_name = "tv";
 foreach $key (keys %{$mailings{$form_name}})
 {
 print "$key => " . ${$mailings{$form_name}}{$key} . "\n";
 }

I have no idea what this syntax is saying or doing and why the two 
different forms of the hash reference are working.

Can some guru explain?

Thank you

Barry Kingsbury
Etnus, LLC.








--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: CPAN Modules continued

2002-06-27 Thread Barry Kingsbury

I, too, am a Win2K user of perl. As I'm using the ActiveEdge 
distribution, I use their perl package manager (ppm) to install modules. 
You can invoke the command from a DOS shell using the ppm3 command (if 
it's in your path). Use the help command to get more information. 
However, it's pretty simple. For example, use the search command to see 
what modules are installable and the install command to install them.

Barry Kingsbury


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Reinitializing an Array

2002-03-13 Thread Barry Kingsbury

I have an array that I wish to reuse. Before I reuse it, I want to clear out all

elements. Both of the following seem to work:

@an_array = "";

and

$#an_array = -1;

I then go on to do something like:

foreach (@foo_array) {
   push (@an_array, $_);
}

Neither seems completely correct although I like the second. Is the second legal
and
portable or did I just luck out?

Is there a better way?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]