[Za-pm] Hashes

Werner Moller wernerm at ifusion.co.za
Thu Jun 5 05:35:12 CDT 2003


Read this doument set up by Robert Pepper, you might find a newer version on
the net. It was my "Newbie Bible" and contains everything you need to know
before getting into the deep end. 

Cheers,
Werner

PS: Read with IE - web archive single file

-----Original Message-----
From: Theunis De Klerk [mailto:theunis at ixpress.co.za]
Sent: 05 June 2003 12:25
To: Spike
Cc: Za-pm at mail.pm.org
Subject: Re: [Za-pm] Hashes


Hi Everyone,

I'm a newbie, especially to Perl.So could someone please explain what
hashes are and what they are used for. From what i see they are sort of
like multi demensional arrays . Is that right?

Muchly appreciated!!!
Theunis


On Thu, 2003-06-05 at 09:32, Spike wrote:
> At 2003/06/05 08:47 AM, Sean Carte wrote:
> >Chapter 4 of the Camel is a good place to start, or end, or go back to
> >repeatedly until it suddenly starts to make sense.
> 
> Oh yes! I know exactly what you mean. All the books seem to get too deep 
> into hashes too quick.
> 
> My advice is to just start trying to put something in a hash and get it
out 
> again - it will make sense eventual - I promise.
> 
> In one of the reference books is says something like "There is no
technical 
> limit to the number of dimensions in a hash array [hashes of hashes of 
> hashes ...] But most human programers stop at 3"
> 
> Start simple:-
> 
> %hash = (
>          car  => 1,
>          wife => 2,
>          dog => 4,
>          kids => 2
>          )
> 
> print "$hash{car}\n";   #  1  expected
> print "$hash{wife}\n;   #   2 expected
> 
> $hash{dog} = 6;
> 
> print "$hash{dog}\n";  #  6 expected
> 
> $hash{dog} ++;
> 
> print "$hash{dog}\n";  #  7 expected
> 
> foreach $key (keys %hash)
> {
>          print "The value for key $key is $hash{$key}\n";
> }
> 
> #  The value for key car is 1
> #  The value for key wife is 2
> #  etc. expected
> 
> 
> Remember that keys are unique so you can use a hash as a unique command.
> 
> 
> 
> 
> 
> 
> 
> Spike Hodge
> 
> UNIX Programmer
> M-Web Technology
> 021 596 8496
> 082 901 5265
> 
> Click here and make M-Web your homepage
> http://homepage.mweb.co.za 


_______________________________________________
Za-pm mailing list
Za-pm at mail.pm.org
http://mail.pm.org/mailman/listinfo/za-pm

############################################################################
#########
This e-mail message has been scanned for Viruses and Content and cleared 
by Ifusion's MailMarshal Gateway
############################################################################
#########


#####################################################################################
Note:
This message is for the named person's use only.  It may contain confidential,
proprietary or legally privileged information.  No confidentiality or privilege
is waived or lost by any mistransmission.  If you receive this message in error,
please immediately delete it and all copies of it from your system, destroy any
hard copies of it and notify the sender.  You must not, directly or indirectly,
use, disclose, distribute, print, or copy any part of this message if you are not
the intended recipient. IFusion (PTY) Ltd and any of its subsidiaries each reserve
the right to monitor all e-mail communications through its networks.

Any views expressed in this message are those of the individual sender, except where
the message states otherwise and the sender is authorized to state them to be the
views of any such entity.

Thank You.
#####################################################################################
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Robert's Perl Tutorial.mht
Type: application/octet-stream
Size: 330946 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/za-pm/attachments/20030605/02f282c8/RobertsPerlTutorial.obj


More information about the Za-pm mailing list