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

Re: What's wrong with this?

From:
Jan Gruber
Date:
January 31, 2002 03:47
Subject:
Re: What's wrong with this?
Message ID:
200201311143.g0VBhl409878@pollux.intern.primacom.net
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.

HTH,
-- 
Jan Gruber              Primacom AG
Central Systems

cat /dev/world | perl -e "while (<>) {(/(^.*? \?) 42 \!/) && (print $1)}"
errors->(c)
_ 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About