Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Parsing out mulitiple blocks of interesting data in files / ignoring other contents

by GeorgMN (Acolyte)
on Mar 02, 2016 at 13:17 UTC ( [id://1156649]=note: print w/replies, xml ) Need Help??


in reply to Re: Parsing out mulitiple blocks of interesting data in files / ignoring other contents
in thread Parsing out mulitiple blocks of interesting data in files / ignoring other contents

Would you be so kind to paraphrase what you are doing in your code please. Thank you again.
  • Comment on Re^2: Parsing out mulitiple blocks of interesting data in files / ignoring other contents

Replies are listed 'Best First'.
Re^3: Parsing out mulitiple blocks of interesting data in files / ignoring other contents
by Athanasius (Archbishop) on Mar 02, 2016 at 13:36 UTC

    The flag variable $in_block keeps track of whether the current line is in a block of interest (because it began with a line starting with the word interface). If we are currently not in such a block, the only thing to be done is to test the current line to determine whether it begins a new such block (if (/^interface/)). If we are already within a block of interest, we will store the current line in the @block array unless the current line (1) begins with the block termination character, !, or (2) begins (after optional whitespace) with the block discard word shutdown.

    When condition (1) is satisfied, we know that the current block has terminated successfully, so we print it out. But if condition (2) occurs, the current block is to be ignored. In either case, the block has ended so we reset the flag to indicate that we are no longer within a block of interest.

    As mentioned above, if we are within a block of interest but the current line satisfies neither condition (1) nor condition (2), then we save the line by pushing it onto the array variable @block, which holds all the lines of the current block that we have read so far. Whenever condition (1) or condition (2) is satisfied, the block ends so we empty the array @block by assigning the empty list to it: @block = ().

    Hope that’s a little clearer,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      Thank you very much sir. Very helpful. Have a nice day.
Re^3: Parsing out mulitiple blocks of interesting data in files / ignoring other contents
by GotToBTru (Prior) on Mar 02, 2016 at 13:36 UTC

    What parts of it are causing you trouble?

    But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-18 05:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found