|
-
Aug 9th, 2005, 01:54 PM
#4
Fanatic Member
Re: CGI Question
Ok..I just got here but I'll try to help 
Regarding the "foreach my $key (keys %results)":
"%results" is a keyed hash array and the code is looping (foreach) through each keyed hash by key name. if you don't specify keys ("(keys %result)") the foreach loop would enumerate by key values instead of key names. The "my $key" is simply specifying what variable you want the enmuerated value to be assigned to.
When using hashes you access values by the key name, thus the "$results{$key}" portion of the next line (the percent sign is used to reference the entire hash while you use the dollar sign when wishing to reference a specific key). The remainder of that line is the apparent math functions.
After what I've covered thus far I imagine that it's obvious to you that with "$percents{$key}" he is assigning a value to another keyed hash and retaining the same key name as is used in the original hash.
sprintf is used to format a string and kfcSmitty is, I believe, correct in his interpetation of that.
Also, if you want or need to investigate other perl functions this page has proven very helpfull to me in the past.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|