Re: help with array within another array
- From: chas.owens@xxxxxxxxx (Chas Owens)
- Date: Tue, 27 Feb 2007 15:39:42 -0500
On 2/27/07, Ravi Malghan <rmalghan@xxxxxxxxx> wrote:
what am I doing wrong here when trying to access thesnip
value john for node1
=========
$SESSION{FirstRun} = 1;
%nodeowner = ("node1", "john", "node2", "nancy");
push(@SESSION, %nodeowner);
print "node1: $SESSION{$nodeowner{node1}}\n";
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";
.
- References:
- Re: help with array within another array
- From: Neal Clark
- Re: help with array within another array
- From: Ravi Malghan
- Re: help with array within another array
- Prev by Date: Re: help with array within another array
- Next by Date: Re: help with array within another array
- Previous by thread: Re: help with array within another array
- Next by thread: Re: help with array within another array
- Index(es):
Relevant Pages
|
|