Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hashes for what &*&*

Status
Not open for further replies.

thendal

Programmer
Aug 23, 2000
284
Hi all!

Why we need to go for hashes ,I didn't understand the hash part ,I didn't used it.Can some one explain why this is there in perl.

I can do every thing with a array,

I believe array can do all the manipulation ,Then why we need an hash.

I don't know may be iam missing another advantage of perl.

Any brief explanation with examples really help me
thanks

Thendal :)

 
well, its for name value pairs...

say you are parsing a form for example...


wouldn't it be nice to have the field name coincide with the value?

so instead of looping through an array and trying to figure out where $array[4] goes.. you can have

$hash{'name'} with a value.

plus there are performance differences...

they aren't useful all the time, but, they are very nice things to have. adam@aauser.com
 
an ordinary array is indexed by number, which is ok

a hash is an array indexed by a string, useful for building lookup tables where indexing by a number wouldn't be the most natural thing to do.
Mike
michael.j.lacey@ntlworld.com
 
Thanks guys,

But inreal time application i found it easier with arrays.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top