|There's more than one way to do things|
Re: Data Structure helpby BrowserUk (Pope)
|on Mar 21, 2003 at 21:11 UTC||Need Help??|
Call me confused, but I can't see how your code snippet relates to the sample data you provided? You have two regex matching against /\s*SNMP\:.../, and one matching /Simple Network Management Protocol/ but the text SNMP does not appear anywhere in your data?
The other peice of information that is missing from your post is an indication of how you wish to use this data structure once it is built. What are you going to do with it?
A large amount of the content of the sample data is repetitious. Whilst it is reasonably easy to build a datastructure to hold that data as is, depending what information you wish to extract from it, it may well be better to consolidate the common elements of the repetitios parts. For example, within each of the sections of the data, all the OID's seem only to vary in the last 2 elements. It might therefore make sense, to eliminate the common prefixes and store the varient parts as sub keys of a hash, under a parent key of the invarient part. rather than stuffing the whole lot in an array. It would also appear that there is some relationship between the NAME: element and the paired OID: element? If this is the case, rather than storing them in parallel arrays, you could pair them as key/value pairs in a hash.
What, if any of the above observations of the data, have any relevance to the application at hand, only you will know, as you haven't explained what that application is. The point being is that there are several ways that you could build a structure to contain the data, but that choosing the best one for your application will depend upon how you need to process that data once you have encapsulated it.
Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.