Juan Gomez
Jul 11 2005, 02:16 PM
Hi
I been hearing about hash on perl
can someone tell me a little bit about that and if you could add a
example
it would be very nice from you thank you
Owen
Jul 11 2005, 09:04 PM
On Mon, 11 Jul 2005 10:16:17 -0500
"Gomez, Juan" <[Email Removed]> wrote:
QUOTE |
I been hearing about hash on perl can someone tell me a little bit about that and if you could add a example it would be very nice from you thank you
|
A hash is a set of relationships, for example
Item Cost
Beans 300
Carrot 200
Apple 250
etc
To create this relationship in perl, use the hash notation
%vegetable_costs = (Beans => 300
Carrots => 200,
Apple => 250 );
To refer to the hash, you use $vegetable_costs{Beans} for the cost of beans etc
for eaxample, your program might have a print statement like
print "The cost of beans is $vegetable_costs{Beans}n";
If you understand that, try putting the words "perl hash" into Google.
Owen