[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Help with a search and replace script in Perl for a big file with no line breaks




> On Jan 27, 2018, at 12:58 AM, tomas wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Fri, Jan 26, 2018 at 03:31:37PM -0800, David Christensen wrote:
> 
> [...]
> 
>> I've "cleaned up" more files than I care to remember.   (Perl s/// is the road to madness for anything but the most trivial cases.)  I wanted to give the OP an idea of what needs to be done and the level of effort involved.
> 
> Pretty arrogant, if you don't even know OP's problem, much
> less the OP himself? Perhaps the language he is dealing with
> is a regular language, in which case regex is... just what
> the doctor ordered? Perhaps the OP has a proof for that?
> What do you know?

I have seen the OP on this list, but don't recall interacting with him/her recently.  So, I had to go by the information provided in his/her post.  My options included:

1.  Make a guess and respond immediately.

2.  Ask for more information and delay.

3.  Do nothing.


I chose #1.


I have found that most posters ignore #2 if they receive any #1.


Perhaps you had additional information you used for your reply?


> Regex is a sharp tool. Much more Perl's variant, which is
> a tad beyond regex. You gotta learn what it's good for and
> what ain't. Like a good cook's knife. You might cut off your
> toe with it, but if you want to dig a trench in your back
> yard, you better use something else.
> 
> BTW, you can build fine parsers with Perl regex. It just makes
> for the first stage (lexer) (and a bit, see above), but it
> works a charm.

I don't disagree that Perl can be used to build lexers and parsers (and a whole lot more); but I would not limit myself to just regular expression operators.


The thesis of my lexer/ parser/ data structure response can be summed up as follows:  given Perl is the most sublime programming language ever invented and tends to impart laziness, impatience, and hubris upon its programmers, it is all too easy for Perl programmers to create programs quickly and easily that give correct output for trivial input, only to then expend great effort and fail miserably when attempting to enlarge those programs to deal with non-trivial and/or incorrect input (e.g. the "real world").  Therefore, Perl programmers must resist laziness, impatience, and hubris, and instead apply computer science to develop systems programming products that can be used and re-used to solve real-world problems.  This has been my unending struggle with Perl (and every other programming language, for that matter).


David

p.s.  I recently switched from a Debian laptop and Thunderbird to a MacBook Pro and Apple Mail.  I don't know if Mail is doing the response indentation levels correctly, and I am unable to adjust them to my satisfaction.  (Mail did include tomas' full e-mail address in the quoted text, which I consider an error; I removed the domain part.)   Perhaps Mail was the root cause of the mis-attribution issues we noticed in a prior thread (?).


Reply to: