in reply to hash as an object property

You need to store a reference to the array, like this:

$node->{smtp} = {timeChanged=>99999999, status=>re};

You can then access individual fields like this:

my $smtp_status = $node->{smtp}{status};

But hopefully you'd be writing accessor functions, right?

--
<http://www.dave.org.uk>

"The first rule of Perl club is you don't talk about Perl club."

Replies are listed 'Best First'.
Re: Re: hash as an object property
by dhammaBum (Acolyte) on Oct 02, 2001 at 13:01 UTC
    Yes, I have sort of been able to do this (with arrays but not hashes as yet - do you have a code snippet?), but as there can be many services per node, how can I create hashes with arbitrary names ?

    I am writing accessor methods and will build all this stuff up once I've got the basics working.

    thanks.

      Perhaps code a bit like this:

      my @services = qw(smtp http ssh); # list of services foreach (@services) { # Somehow get the details for the given service on # the given node. Here I'm assuming the existance of # a function that returns the required hash. my %details = get_details($node, $_); $node->{$_} = \%details; }
      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you don't talk about Perl club."