Hello list,

I've been playing with perl going back to the 4.x days, mostly simple
scripts to monitor server or application daemons, kick off and manage
backups, or read log files.. While some of these programs are fairly
complicated, none have more than just tickled the more sophisticated
features of perl.. You don't need a Maserati if you're only going to the
store for bread and eggs.. Lately I took on a new project in which I have to
be able to deal with a fairly complicated data set, and I need to get that
fancier car running.. 

To be able to manipulate the information, I created a simple data structure
of 3 parts.. A top level structure which has a hash containing the second
level structure.. This hash contains additional structures of which one is a
hash, leading to the bottom level structure.. Though what I am using is a
bit more involved, for sake of simplicity consider the structure as follows:

        $Policy = {
                NAME => $PlcyName,
                DESCRPT => $PlcyDesc, 
                INSTNCE => { %Instance }, 
        };

        %Instance = (
                $CondID => {
                        DESCRPT => $InstDesc,
                        ACTIONS => {%PlcyActions},
                },
        );

        %PlcyActions = (
                START => {
                        SEVRTY  => $Severity,
                        TEXT    => $MsgText,
                        AUTACTS => $AutoAct,
                },
                 CONT => {
                        SEVRTY  => $Severity,
                        TEXT    => $MsgText,
                        AUTACTS => $AutoAct,
                },
                END => {
                        SEVRTY  => $Severity,
                        TEXT    => $MsgText,
                        AUTACTS => $AutoAct,
                },
        );

I need to be able to write to and read from the structure at any point.. I
can access either of the scalars in the top level fairly easily.. 

        print $Policy->{NAME}

prints the value assigned to $PlcyName.. The problems develop when I try to
access the second level structure.. 

If want to access the value stored in $InstDesc, I can through
$Instance{$CondID}{DESCRPT}.. However I can't access the $InstDesc scalar
from the top.. If I try to print the obvious (at least to me):

        $Policy->{INSTNCE}{$CondID}{DESCRPT}

I get the "use of an uninitialized in concatenation" warning.. If I try to
print the following:
 
        $Policy->{INSTNCE}->$Instance{$CondID}{DESCRPT}
 
  I'd get:
 
        HASH(0x235f34)->BadIncident
        (Note: "BadIncident" is current value of $InstDesc)
 
I've read chapters 8 & 9 of the camel book so many times I can't tell you,
and chapter 5 a few times from Randal Schwartz's llama book.. I also done
more   Google searches than I care to remember.. So please don't reply with
links to FAQ's or docs if that is all you have to say..

Can someone explain how to access $InstDesc?? Also please explain how I
would access (that is read from or write to) to the $Severity scalar on the
bottom structure..

Thanks in advance.. flk 

p.s. I need to get this working or the boss has threatened to have it
written in vb script.. Please help..

flk k


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


Reply via email to