From:                   "Jackson, Harry" <[EMAIL PROTECTED]>
> Can anyone make this a bit faster for me. I am loading a database from
> Oracle into mysql (dont ask). These conversions are taking a long time
> and are making the browser time out. The $table_name[7] is a worklog
> that can be 2000 characters long and $table_name[2] is an epoch date.
> 
> while (@table_name = $sth->fetchrow_array()) {
> 
>    #Change to proper date.   
>    $table_name[2] = localtime($table_name[2]);
> 
> while($table_name[7] =~ /([0-9]{10})/g) {
> 
>     my  $epoch = $1;
>     my $t = localtime($epoch);
>     $table_name[7] =~ s/[0-9]{10}/\n\n$t/g;

What what what???

First you wanna loop over all ten digits long numbers in the string 
and then you replace them ALL with the date that belongs to the first 
one. Not what you wanted I believe.

You want something like this:

        $table_name[7] =~ s/([0-9]{10})/localtime($1)/ge;

in place of the whole loop.


>     $table_name[7] =~ s/\cd|\cc/. /g;

How is this related to the loop???

> 
> }
> 
> while($table_name[7] =~ /([0-9]{9})/g) {
> 
>     my  $epoch = $1;
>     my $t = localtime($epoch);
>     $table_name[7] =~ s/[0-9]{9}/\n\n$t/g;
>     $table_name[7] =~ s/\cd|\cc/. /g;
> }

This loop may be changed to a single s/// statement, actually there 
is no reason why you could not merge it with the first one.

So at last the whole code may be stripped down to:

while (@table_name = $sth->fetchrow_array()) {
        #Change to proper date.   
        $table_name[2] = localtime($table_name[2]);
        $table_name[7] =~ s/([0-9]{9,10})/localtime($1)/ge;
        $table_name[7] =~ s/\cd|\cc/. /g;
        # done with fixing data.

        ...
}


HTH, Jenda
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
                                        --- me


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to