Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Non-fixed data in record

by brassmon_k (Sexton)
on Aug 31, 2001 at 22:30 UTC ( #109477=note: print w/ replies, xml ) Need Help??


in reply to Re: Non-fixed data in record
in thread Non-fixed data in record

Wow,

You're good! I mean, I understand it sort of. OK, you interpretted what I said exactly the righ way. That "PCSPLMNCallDataRecords" is at the top of every record block and then it is immediately followed by a subheading such as: mSTerminating, mSOriginating, transit, and like 3 others and everything below that are data lines that can be in different positions by 3 to 4 lines or more.

I know you understand the question and posted a good answer but I have to understand the answer. What ever happened to 2+2=4. Wow, see that's why I have a hard time with hashes and arrays.
The Brassmon_k


Comment on Re: Re: Non-fixed data in record
Ask your question, then actually try to understand the answer before responding!
by dragonchild (Archbishop) on Aug 31, 2001 at 22:38 UTC
    brassmon_k ... Instead of starting with something as complex as your problem seems to be, why not start with something really simple and actually understand how Perl does multi-level data structures? You seem to want to eat your cake and have it, too.

    Perl understanding does not come very quickly, nor very easily. You have to be willing to work at it, just like anything else. Perl has a very deceiptfully easy learning curve, but it still has all the complexities of a C or a LISP.

    Another thing, and this is much more nitpicky - I would never classify someone who didn't understand multi-level data structures as intermediate in any language, especially not Perl. Look at it as your graduation-from-beginner test. You don't even need to understand how references work (though it helps, in the long run). Look back at my answer and try to understand it.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Vote paco for President!

(Re) x 3: Non-fixed data in record
by dmmiller2k (Chaplain) on Sep 07, 2001 at 01:34 UTC

    Thanks for the compliment. I see what you mean, though. What seemed to me to be a fairly simple deconstruction of the data turns into a fairly complex multilevel perl data structure.

    The trick to understanding these (at least what worked for me) is to realize that arrays (and hashes) can only store scalars, not other arrays (or hashes).

    Conveniently enough, references to arrays (or hashes) ARE scalars. So rather than an array of hashes (or hash of arrays, or whatever), you can have an array of hashrefs (or a hash of arrayrefs, etc.).

    Looking at your data, the first thing that struck me (as it apparently did to several other respondents) was that the lines below 'mSTerminating' appeared to suggest a hash (key/value pairs).

    Surmising (apparently correctly) that 'mSTerminating' was a type or descriptor name (i.e., that there might be more than one instance of it), I figured that there should be an array of references to the above hashes.

    Finally, we need a hash to associate a reference to this array with the string 'mSTerminating'.

    So the data itself suggests the structure: a hash which associates types (e.g., 'mSTerminating') with (a reference to) an array of instances, themselves represented by hashrefs.

    Hope this helps.

    dmm

    Just call me the Anti-Gates ...
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://109477]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2014-08-20 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (107 votes), past polls