Front page | perl.perl5.porters |
Postings from September 2011
Taking perl to the next level
Thread Next
From:
Kleinburg, Frank
Date:
September 27, 2011 19:33
Subject:
Taking perl to the next level
Message ID:
0CBB867BE91EA54DAD522D8D1AF31A3601A92F@NDHEP50002.na.corp.mckesson.com
Hello list,
I've been playing with perl going back to the 4.x days, mostly simple scripts to monitor this or that process, or read log files.. While some of these perl based programs did get fairly complicated, none have been very sophisticated.. You don't need a Maserati if all you are doing is 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 need, I created a simple little 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..
I need to be able to write to and read from the structure at any point.. (to save some space, the structure is one left side, and my discussion and questions continue on the right side of the screen.. Think of it as a picture on the left, and text wrapping around it..)
#
$Policy = { # I can access either of the scalars in the top level fairly
NAME => $PlcyName, # easily.. print "$Policy->{NAME}" prints whatever I have
DESCRPT => $PlcyDesc, # assigned to $PlcyName.. The problems develop when I try to
INSTNCE => { %Instance }, # access the second level structure..
}; #
# If want to access the value stored in $InstDesc, I can do it
%Instance = ( # through $Instance{$CondID}{DESCRPT}.. However I am not sure
$CondID => { # how to access the $InstDesc scalar from the top
DESCRPT => $InstDesc, #
ACTIONS => {%PlcyActions}, # If I try to print the following:
}, # "$Policy->{INSTNCE}->$Instance{$CondID}{DESCRPT}"
); # I'd get:
# "HASH(0x235f34)->BadIncident"
%PlcyActions = ( # (Note: "BadIncident" is current value of $InstDesc)..
START => { #
SEVRTY => $Severity, # I've read chapters 8 & 9 of the camel book so many times
TEXT => $MsgText, # I can't tell you, and chapter 5 a few times from Randal
AUTACTS => $AutoAct, # Schwartz's llama book.. I also done more Google searches
}, # than I care to remember..
CONT => { #
SEVRTY => $Severity, # Can someone explain how to access $InstDesc?? Also please
TEXT => $MsgText, # explain how I would access (that is read from or write to)
AUTACTS => $AutoAct, # to the $Severity scalar on the bottom structure..
}, #
END => { #
SEVRTY => $Severity, # Thanks in advance.. flk k
TEXT => $MsgText, #
AUTACTS => $AutoAct, #
}, #
); #
#######################################################################################################
Thread Next
-
Taking perl to the next level
by Kleinburg, Frank