On 2/27/07, Ravi Malghan <[EMAIL PROTECTED]> wrote:
what am I doing wrong here when trying to access the
value john for node1
=========
$SESSION{FirstRun} = 1;
%nodeowner = ("node1", "john", "node2", "nancy");
push(@SESSION, %nodeowner);

print "node1: $SESSION{$nodeowner{node1}}\n";
snip

Off that bat I would say there are several issues with this code:
* you are using uppercase characters for variable names, convention
says only bareword file handles should be all uppercase
* you have an array and a hash named SESSION (which is confusing)
* you don't appear to be using the strict module ("use strict" at the
top of the code)
* you are creating a useless intermediate variable (%nodeowner)
* you are trying to get data out of the hash %SESSION that you put in
the array @SESSION.

Without more context I would rewrite your code like this:

#!/usr/bin/perl
use strict;

my %session;

$session{FirstRun} = 1;
$session{node1} = 'john';
$session{node2} = 'nancy';

print "node1: $session{node1}\n";

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


Reply via email to