Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Extract Block Of Text From Log

by LanX (Cardinal)
on Nov 21, 2018 at 12:22 UTC ( #1226126=note: print w/replies, xml ) Need Help??


in reply to Re: Extract Block Of Text From Log
in thread Extract Block Of Text From Log

> Well, i'd use a classic state machine for this problem, then we can work line-by-line, without having to load the whole file into memory.

Sorry for nitpicking, but ... :)

Flip/Flop solutions are state machines and do it in one pass.

I even demonstrated that you can safely nest them, hence the technology is "scalable".

The advantage of your solution is that it's easily portable to other languages, i.o.W. it ignores Perl's possibilities. ;-)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^3: Extract Block Of Text From Log
by cavac (Curate) on Nov 23, 2018 at 10:04 UTC

    I fully support your argument. I just like to write easy-to-read easy-to-port examples.

    When you write stuff that might still have to be supported in a couple of decades, then making it easy to read and understand is much more important than making it "nice and fast and only understandable by perlmonks" ;-)

    perl -e 'use MIME::Base64; print decode_base64("4pmsIE5ldmVyIGdvbm5hIGdpdmUgeW91IHVwCiAgTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duLi4uIOKZqwo=");'
      > only understandable by perlmonks" ;-)

      I disagree because state-machines need a lot of documentations and flip/flop is well documented in perldoc.

      At worst you'll just need to add a link in the comments.

      > just like to write easy-to-read easy-to-port examples.

      So consequently you use goto instead of loop constructs, to keep it easily portable to assembler? ;-)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        I very rarely use goto, but there are a few cases where it is the correct function to use.

        perl -e 'use MIME::Base64; print decode_base64("4pmsIE5ldmVyIGdvbm5hIGdpdmUgeW91IHVwCiAgTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duLi4uIOKZqwo=");'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2021-05-07 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (82 votes). Check out past polls.

    Notices?