dimmesdale has asked for the wisdom of the Perl Monks concerning the following question:
I come from a C/C++ background, so when I want to create an ADT (advanced data type), I use struct or class. It's so easy.
I want to create a heterogenous data structure in perl, and I would appreciate some input -- currently I'm getting an error about coercing a hash into an array (or was it an array into a hash ... :)
Here's a quick summary of what I need:
| Example | Keep track of | Varies by |
| 0 | Index | Subdirectory ... File ... Measurment |
| ParserObject1 | Parser | Subdirectory ... File |
| HRT | Name | Measurement |
| Heart Rate | Label | Measurement |
| PRFN1 | Conditions | constant |
| Low-Hour VFR | Groups | constant |
| Heart rate < 50 | Invalid data | constant |
| 0404 -> 1 | Substitutions | constant |
For the invalid data, I thought that the value could be something like this --
[ ['measurement1', [ ['test subject number', 21, 27], ['value', 50], ... ], ... ], ... ]
Where 21 was the min, 27 the max, etc.
I'm not sure that any of that is needed by you, so I'll stop there.
However, my current method of referring to these data is as such:
$info->{subdirectory}->{file}->[measurement] = INDEX; $info->{subdirectory}->{file} = PARSER; $info->[measurement]->{name} = NAME; ...etc., according to what it varies by...
My question to you: Is this, as I suspect, the source of the 'hash coercion problem'? and if so, what data type should I make ... possibly should I go all out and make a module with accessors and constructors and the full nine yards, etc.?
Your experience and help is most apprecieted. </CODE>
The actual things I need to keep track of are changing somewhat as I'm becoming aware of what I need ... your answer need not be too specific to the data I have, though it could.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with ADT
by VSarkiss (Monsignor) on Jul 24, 2002 at 19:51 UTC | |
by dimmesdale (Friar) on Jul 24, 2002 at 19:53 UTC | |
|
Re: Help with ADT
by DamnDirtyApe (Curate) on Jul 24, 2002 at 19:50 UTC | |
|
Re: Help with ADT
by sauoq (Abbot) on Jul 24, 2002 at 20:20 UTC | |
by dimmesdale (Friar) on Jul 24, 2002 at 20:34 UTC | |
|
Re: Help with ADT
by dragonchild (Archbishop) on Jul 24, 2002 at 21:23 UTC | |
by Abigail-II (Bishop) on Jul 25, 2002 at 11:33 UTC | |
by dragonchild (Archbishop) on Jul 25, 2002 at 14:10 UTC | |
by Abigail-II (Bishop) on Jul 25, 2002 at 14:20 UTC | |
by dragonchild (Archbishop) on Jul 25, 2002 at 14:38 UTC | |
| |
|
Re: Help with ADT
by Ryszard (Priest) on Jul 26, 2002 at 11:26 UTC |