in reply to Re: Define string on current line, then match other lines with string below the line
in thread Define string on current line, then match other lines with string below the line

First: thank you.

Second: HoHoA? That's one Ho short of a Santa-A (Canadian?). Seriously though, I have yet to venture into hash-land, nevermind hashes of arrays, and certainly not Santas who are not playing with a full deck of Ho's.

Since it's obviously time for me to get into hashes, do you have any examples like this one where data from a file is pushed to the hash, as opposed to the user defining it? Unfortunately nobody at my work cares that I can create a hash with different fruits and vegetables from my mind.

And third, thanks for saying TCP because it made me realize I don't need to look for UDP connections. I will work that into the regex.

Great learning experience, thanks again to everyone who replied.

  • Comment on Re^2: Define string on current line, then match other lines with string below the line

Replies are listed 'Best First'.
Re^3: Define string on current line, then match other lines with string below the line
by Athanasius (Cardinal) on Oct 05, 2014 at 16:04 UTC
Re^3: Define string on current line, then match other lines with string below the line
by mr_mischief (Monsignor) on Oct 06, 2014 at 18:14 UTC

    Yeah, I was a bit concerned that a hash of hashes of arrays was a bit complex in this case. Sometimes I find it easier to think about the levels backward. There's an array of the lines kept in 'line', and a reference to each 'line' is kept in its own $match hash. A reference to each $match is kept in %connection to hold it all together. The 'count' is just another branch of that tree. Set $DEBUG to 1 and look at the data structure.

    I've found some quotes about data structures I'd like to share before I start giving bibliography.

    • "Bad programmers worry about the code. Good programmers worry about data structures and their relationships." -- Linus Torvalds
    • Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won't usually need your flowcharts; they'll be obvious. -- Fred Brooks.
    • Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming. -- Fred Brooks
    • "It is better to have 100 functions operate on one data structure than to have 10 functions operate on 10 data structures." —Alan J. Perlis
    If you don't know who those people are or why I've chosen them to quote, then I suggest a bit of research on them. Their writing will make you a better programmer. As will stuff by Rob Pike, Al Aho, and many others for that matter.

    Besides the wonderful Modern Perl already mentioned in the thread, there are other resources, too.