On Thu, 06 Jan 2000, Eric L. Brine wrote:
> > You have to store a reference to the hash, ie
> > 
> > $Session->{Stuff} = \%stuff;
> > not
> > $Session->{Stuff} = %stuff;
> 
> 
> \%stuff is not a reference to a hash, it's a reference to each key and
> value in the hash. I don't think you'll ever have to use \ on arrays or
> hashes. The only way to get a hash ref is by using the {} operator. e.g.:
> {%stuff}  Of course, you know how two copies of the data, so be careful.

{%stuff} is not a reference to %stuff. It's a reference to a newly created
hash. Be very careful using this syntax, it may not do what you expect it
to do:

%hash = (1 => 'perl');
$a = {%hash};
$hash{2} = 'apache';
print $a->{2};

If $a was a reference to %hash then it would print 'apache'.

-- 
<Matt/>

Details: FastNet Software Ltd - XML, Perl, Databases.
Tagline: High Performance Web Solutions
Web Sites: http://come.to/fastnet http://sergeant.org
Available for Consultancy, Contracts and Training.

Reply via email to