Re: help with array within another array



well first of all you're using the syntax for non-associative arrays (normal @arrays). your hash declarations should look like this:

%nodeowner = (node1 => "john", node2 => "nancy");
%nodeseverity = (node1 => 5, node2 => 10);


as for %SESSION, you could make a hash with reference to hash values:
%SESSION = (owner => \%nodeowner, severity => \%nodeseverity);

and access john like this:
$SESSION{owner}->{node1};

(without understanding any more of what you're doing than you have written here) it seems like you might want to consider using the node identifier as the first key in %SESSION, and make the value a reference to hash keyed by the owner and severity:

%SESSION = (
node1 => {
owner => "john",
severity => 5,
},
node2 => {
owner => "nancy",
severity => 10,
}
}

*shrug*. seems like a more natural way to refer to it to me.
$SESSION{node1}->{owner} = john
$SESSION{node1}->{severity} = 5,
etc.

take a look at perldoc perlreftut


-Neal
On Feb 27, 2007, at 11:53 AM, Ravi Malghan wrote:

Hi: I just can't seem to figure this out.
I am trying to declare two associative array
(%nodeowner and %nodeseverity) within another array
called %SESSION

For example
%nodeowner = ("node1", "john", "node2", "nancy");
%nodeseverity = ("node1", 5, "node2", 10);

How do I declare %SESSION containing %nodeowner and
%nodeseverity. And how do I access say the value John
give node1 from the nodeowner array that is in
SESSION?

TIA
Ravi



______________________________________________________________________ ______________
Now that's room service! Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/



.



Relevant Pages

  • Re: Looking to improve program
    ... You generally should declare your variables in the smallest scope ... array. ... Now that you have the hash, you can use it instead of four nearly ... There's also no real reason to be assigning ...
    (comp.lang.perl.misc)
  • Re: 2 dimension arrays
    ... > How do I declare an array as a session variable? ... as you have a *reference* to this array, there is really only one array ... >> Andrew wrote: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: help with array within another array
    ... array @SESSION. ... I am trying to declare two associative array ... (%nodeowner and %nodeseverity) ...
    (perl.beginners)
  • Re: 2 dimension arrays
    ... "Hans Kesting" wrote: ... >> How do I declare an array as a session variable? ... No need to "put the changed array back in the Session". ...
    (microsoft.public.dotnet.framework.aspnet)
  • return array/hash ref from function
    ... I have a number of functions in a program I'm writing that return a reference to ... an array or hash. ... I declare the variable to return with 'my' ...
    (perl.beginners)