in reply to Re: Hashes and Refs
in thread Hashes and Refs

Sorry for that.. I posted the code from the original file... it's supposed to be $fields later.
and I thought that a {} will delimit hash elements, and () delimits array elements.
so it's still a regular hash here...:(
Chady | http://chady.net/

Replies are listed 'Best First'.
Re: Re: Re: Hashes and Refs
by arturo (Vicar) on Mar 08, 2001 at 02:45 UTC

    Here's a way to think of it that helped me (though it's a little indirect, this is how I latched onto the difference): the => operator you see in hash construction is really just a comma that says "quote barewords to the left of me." So it's a pretty subtle difference between:

    my %hash = (1, 2, 3, 4, 5, 6);
    and
    my %hash = (1=>2, 3=>4, 5=>6);

    Both do the same thing; the only difference comes out if you want to have strings as the keys, using the => makes things look nicer, and lets the key/value relationship stand out visually =)

    my %quotes_hash = ("bob","carol", "ted","alice"); # vs. my %noquotes_hash = (bob=>"carol", ted=>"alice");

    In a lot of respects, hashes are just lists, at least as far as their construction is concerned ... of course the internals are different =)

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor