develooper Front page | perl.beginners | Postings from January 2002

Re: What's wrong with this?

Jan Gruber
January 31, 2002 03:47
Re: What's wrong with this?
Message ID:
Hi, Gary !
On Thursday 31 January 2002 12:16 pm, you wrote:
> Thanks, I tried and didn't understand it.

Dit it work at all ?

> > I think %data = $q->vars would be better to read and I'm not sure if the
> > Vars() function returns a reference or a hash.

Ok, i'll try....

A hash is a data comfortable data structure, where you can stuff lots of 
things in and find it later on via the given key. 

A simple example would be:  $hash{key} = value.

Since the key has to be unique, one could use a hash for dupechecking, 
sorting things etc.pp

A reference is a pointer to a variable: $ref = \%hash.

So everytime one uses $ref{foo}, %hash{foo} is returned. All actions done 
with $ref (insert data, delete data) are directly manipulating %hash.
This is often used to send a hash as parameter to a subroutine. If one uses a 
ref here, all actions in the sub go back to the original hash and just in 
case you use huge hashes, it saves some time, since you dont have to pass the 
whole big hash, but rather a reference to it.

Jan Gruber              Primacom AG
Central Systems

cat /dev/world | perl -e "while (<>) {(/(^.*? \?) 42 \!/) && (print $1)}"
_ Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About