Re^2: [Solved]Need to extract a particular block of lines between two patterns
by Laurent_R (Canon) on Nov 09, 2017 at 09:00 UTC
|
Hi sundialsvc4,
chengchl's question was essentially: how can I use the flip flop operator and pick up only the second START .. END block of text.
Even assuming your suggested code were correct Perl code (which it isn't) and would run, it still wouldn't do what the OP was asking for, but only mimic the flip flop operator.
The flip flop operator has a somewhat surprising edge-case behavior (when exactly is it reset) which might justify writing explicit code, but your code (if it worked) would not do what was asked for.
Update: s/would do what/would not do what/;. Thanks to hippo for noticing the missing negation at the end of my last sentence above. Now fixed. | [reply] [d/l] [select] |
Re^2: [Solved]Need to extract a particular block of lines between two patterns
by eyepopslikeamosquito (Archbishop) on Nov 09, 2017 at 21:43 UTC
|
Based on your reply, and on these old nodes:
- Re: Comparing two hashes-help: "I often find it useful to describe logic like this in terms of a finite-state machine (FSM)"
- Re: Spliting file + removing column: "For this, I use “finite-state machine (FSM)” logic"
- Re: ADSI groups users: "I naturally look at such problems with an eye toward so-called finite state machine logic"
- Re: IO::Socket client does not detect when server network connection dies: "Logic like this is sometimes well designed using Finite State-Machine (FSM) logic"
- Wisdom on how to build a "stressful simulation test" with Selenium & POE: "Each actor is basically an individual finite-state machine"
- Re: A way to avoid repeated conditional loops: "Call it “a flag variable” if you want to, but this is a classic place for a finite-state machine (FSM) algorithm"
- Re: Perl/Tk code structure: "A typical design for the shepherd process is a Finite-State Machine (FSM), or more likely, two FSMs"
- Re: how did blocking IO become such a problem?: "The entire life cycle of a request, and much of the outer request-handling heuristics, is most easily described using a finite-state machine (FSM) algorithm"
- Re: Clubbing array elements together:: "I prefer to solve such problems using a Finite-State Machine (FSM) algorithm"
- Re: File Find/Replace with the replacement coming from part of earlier matched string: "This is an absolutely classic case for a “finite-state machine (FSM)” algorithm"
- Re: How to check if successfully logged in?: "it must be a finite-state machine (FSM) design, because in the final analysis the host web-site is driving the bus ... Fact of the matter is, a production mechanize-script is often two FSMs"
- Re: Reading concurrently two files with different number of lines: "It might be useful for you to look at the concept of Finite-State Machine (FSM) algorithms as a source of ideas for generalized solutions to these problems"
- Re: RFC: Simulating Ruby's "yield" and "blocks" in Perl: "these can be used to implement finite-state machines (FSMs)"
- Re: Selecting HL7 Transactions: "this sort of thing is most-easily handled by finite-state machine (FSM) techniques"
- Re^2: Too much recursion: "For dealing with very complicated inputs, the notion of a Finite-State Machine (FSM) can be useful"
- Re: Sorting through a file with multiple tables and extracting data: "The general approach is that of a finite-state machine (FSM)"
- Re: Is this a simple, robust, and maintainable design?: "sounds like a Finite-state machine"
- Re: Can I/O operations on the same IO::Socket be executed in different threads?: "That one thread, with simple FSM = Finite-State Machine logic, can keep track of them all"
- Re: Algorithm inspiration required. (2018 update): "the aforementioned FSM algorithms might prove to be extremely useful and of course much-preferable" (Buk and YourMum reply)
it appears your manic obsession with finite state machines (FSMs) continues unabated.
I have a suggestion.
Instead of making yet another knee-jerk "use a FSM!!!" exhortation to almost any random question,
how about giving something useful and lasting to the community, by writing a nice meditation -- along with complete, working, tested code and tests --
describing your favourite and most instructive FSM implementation, from the presumably hundreds
you've written during your illustrious career.
Update (2021): SunnyD bothered to log in to give an attaboy to perlfan for suggesting a DFA in Re: Augmenting and reducing data structures.
| [reply] |
|
|
| [reply] |
|
|
Why do you or so much energy into replying?
Everything was already said, just link to an overview post summing it up.
I don't share your confidence that "everything was already said".
Though I could link to a node that summarises the observed behaviour patterns,
that does not solve the mystery of the "why" behind the behaviour.
Note that your summary link does not address the "why" behind the behaviour.
Please note that -- unlike many of his detractors --
sundial does not (deliberately) hide behind a cloak of anonymity,
so simplistic "psychology of internet troll" arguments do not apply.
If anyone with psychology qualifications can provide some insight, I'm all ears.
| [reply] |
|
|
|
|
|
|
|
Re^2: [Solved]Need to extract a particular block of lines between two patterns
by Anonymous Monk on Nov 09, 2017 at 02:19 UTC
|
Thank you for your javascript solution to a perl question. When I do run it in perl I get:
Bareword found where operator expected near "// state"
elseif should be elsif
syntax error near "// state "
Bareword "false" not allowed while "strict subs" in use
Bareword "false" not allowed while "strict subs" in use
Bareword "false" not allowed while "strict subs" in use
Bareword "true" not allowed while "strict subs" in use
| [reply] [d/l] |
Re^2: [Solved]Need to extract a particular block of lines between two patterns
by Anonymous Monk on Nov 09, 2017 at 09:25 UTC
|
And, I would certainly insist that anyone on my team must create a series of automatic (Test::Most) tests to demonstrate that the logic actually does work
I know someone in your team who doesn't test their code
| [reply] |
Re^2: [Solved]Need to extract a particular block of lines between two patterns
by Anonymous Monk on Nov 09, 2017 at 10:38 UTC
|
Code that does not even compile, trash words, nothing of value, as usual. The ravings of a sad, mad old man. | [reply] |
|
|
| [reply] |
|
|
| [reply] |
|
|
|
|
|
|
| [reply] |
Re^2: [Solved]Need to extract a particular block of lines between two patterns
by Anonymous Monk on Nov 09, 2017 at 10:23 UTC
|
| [reply] |