Neal Clark wrote:
> you are working with two different variables.
> 
> On Feb 27, 2007, at 12:24 PM, Ravi Malghan wrote:
> 
>> what am I doing wrong here when trying to access the
>> value john for node1
>> =========
>> $SESSION{FirstRun} = 1;
> 
> this line creates a _hash_, %SESSION with one element (keyed by 
> FirstRun, value is 1).
> 
>> %nodeowner = ("node1", "john", "node2", "nancy");
>> push(@SESSION, %nodeowner);
> 
> here you're pushing to an array that perl has never heard of,  @SESSION,
> so perl goes ahead and makes an empty one for you before it  pushes your
> hash to it. you end up with an array of one element where  $SESSION[0] =
> %nodeowner

Incorrect.

%nodeowner = ("node1", "john", "node2", "nancy");
push(@SESSION, %nodeowner);

Is equivalent to:

push(@SESSION, ("node1", "john", "node2", "nancy"));

Except that the order of the keys and values could be in any arbitrary order.

(A hash in list context is just a list.)



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to