Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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


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

Replies are listed 'Best First'.
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.


    Just call me the Anti-Gates ...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://109477]
[QM]: choroba, who or what are you hiring?
[choroba]: Perl programmers

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2017-06-29 10:12 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (658 votes). Check out past polls.