APM: creating a hash

Ian Ragsdale ian at SKYLIST.net
Fri Apr 4 17:56:40 CST 2003


On 4/4/03 5:49 PM, "Goldilox" <Goldilox at teachnet.edb.utexas.edu> wrote:

> I'm having trouble getting a hash to see everything like I want it too.
> I need some hash values to have single quotes around them, for example
> so I try this:
> 
> %stypes={"'RA'"=>"Rainfall",
> "'ST'"=>"Stage and Flow"
> };
> 
> Error: Reference found where even-sized list expected
> 
> I've created a reference?
> 

Yes, you've created a reference.  The curly brackets make it a hash
reference, so what you actually want is parentheses, like this:

> %stypes=("'RA'"=>"Rainfall",
> "'ST'"=>"Stage and Flow"
> );

It's a common mistake - I've been writing perl for years and still do that
every now and then. :)





More information about the Austin mailing list