Re: OT: Help with a search and replace script in Perl for a big file with no line breaks
> On Jan 24, 2018, at 11:40 PM, deloptes <deloptes@gmail.com> wrote:
>
> David Christensen wrote:
>
>> I used to subscribe to Perl Beginners, but the administrator got draconian
>> about discussing other languages, I dropped, and now I appear to be
>> banned:
>
> The way you are writing, no wonder you are banned.
Yes -- I'm such an insensitive ass. ;-)
> Read once again the original post.
Okay, read again. But, I fail to understand how reading the OP's words are related to my insensitivity...
>> If you attack the files with raw Perl, you're going to be writing a lexer
>> and parser to read the database dump into a data structure, and then doing
>> your work against that (perhaps by dumping it to a common format and then
>> writing tools against that). If you don't have an EBNF grammar for the
>> dump, you'll have to figure it out. Getting the lexer/ parser right, and
>> verifying that you got it right, is going to be a lot of work.
>>
>
> you don't know what OP wants to do - OP did not say that
The OP said:
> On Jan 24, 2018, at 11:14 AM, rhkramer@gmail.com wrote:
>
> The file is ugly, with lots of extraneous characters--I want to run a series of
> regular expression search and replace commands over the file to clean it up.
I've "cleaned up" more files than I care to remember. Lexing, parsing, and EBFN are the standard computer science tools for tasks such as this. (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.
> On Jan 24, 2018, at 11:40 PM, deloptes <deloptes@gmail.com> wrote:
>
> David Christensen wrote:
>
>> 2. Get a tool that understands the dump file (such as the original
>> database engine), import the dumps, and then generate queries/ reports/
>> etc. as desired to meet your needs.
>
> This is probably the best solution to the problem - import the dump and
> export in a friendly way
Laziness is the first chief virtue of (Perl) programmers [1]. Hopefully, the OP has this option.
David
[1] https://en.wikiquote.org/wiki/Larry_wall
Reply to: