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.
In reply to Help with ADT by dimmesdale
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |