[Jax.PM] ~9M lines of data

Aaron Johnson solution at gina.net
Mon Oct 14 16:21:33 CDT 2002


Have you considered the inverse?  Looking at what you don't want vs.
what you want.

while (<FILE>) {

next if /^\INSERT/;
next if /^\#/;
print NEWFILE $_;

}

then on the command line just do something like:
perl -pi -e 's/\n{2,}/\n/g;

To clear up the multiple \n entries.

Just a thought, no testing done.

Aaron

On Mon, 2002-10-14 at 17:07, William C (Bill) Jones wrote:
> [a jax.PM member posting]
> On 10/14/02 4:36 PM, "J Proctor" <jproctor at marlboro.edu> wrote:
> 
> > I was going to ask why you don't watch for /^);/ (or index of it) instead
> > of the "dumping data" line, but it occurred to me that there might be
> > other lines with that, and you go through the process of setting $flag to
> > 0 when it's already 0.
> 
> Yes, I found it faster to just let it get reset to false each trip.
> 
> > Didn't realize index() was that much faster, though.  Curious if you'd
> > like to try a version each way and report back.  Anchoring the regexes to
> 
> The code I wrote runs about the same as the code Greg wrote; although his
> doesn't quite generate the data the way I want, but I am still trying to
> break his more so mine will be much faster :)  What I want is -
> 
> CREATE TABLE ... (
> Row
> Row
> Row
> )
> 
> Then when I see Dump Data, the Flag become False so I can skip all the
> INSERT INTO statements...
> 
> > Never actually benchmarked it myself, but in this case, we know that
> > the exact string is "CREATE TABLE ", with actual Ascii 32 spaces; I can
> > imagine that \s *might* be a hair slower in a regex.
> 
> 
> Actually, recent Perl versions the RegEx and the Index (substr, rindex,
> index) stuff - performance is about the same.
> 
> -Bill-  :]
> _Sx____________________
>   ('>    iudicium ferat
>   //\   Have Computer -
>   v_/_    Will Hack...
> 
> 
> _______________________________________________
> Jacksonville-pm mailing list
> Jacksonville-pm at mail.pm.org
> http://mail.pm.org/mailman/listinfo/jacksonville-pm
> 




More information about the Jacksonville-pm mailing list