Re: HOW TO PARSE A VAST FILE!
From: Tore Aursand (tore_at_aursand.no)
Date: 03/19/04
- Next message: Tore Aursand: "Re: Regular Expressions Question"
- Previous message: Matt Garrish: "Re: Can somebody please help me"
- In reply to: news.hinet.net: "Re: HOW TO PARSE A VAST FILE!"
- Next in thread: Matthew Braid: "Re: HOW TO PARSE A VAST FILE!"
- Reply: Matthew Braid: "Re: HOW TO PARSE A VAST FILE!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 19 Mar 2004 02:07:49 +0100
On Fri, 19 Mar 2004 01:05:53 +0800, news.hinet.net wrote:
> 163.22.3.7 2003/06/28 0011:00:42 PASSED
> http://proxy.ncnu.edu.tw/cgi-bin/squidGuard.cgi?clientaddr=163.22.28.128&clientname=ip128.puli28.ncnu.edu.tw&clientuser=&clientgroup=general-clients&targetgroup=moe&url=http://gatorcme.gator.com/gatorcme/autoupdate/precisiontime.ini
> 163.22.3.7 2003/06/28 0011:00:42 PASSED
> http://163.22.3.7/gatorcme/autoupdate/precisiontime.ini
> 163.22.3.7 2003/06/28 0011:00:43 PASSED
> http://proxy.ncnu.edu.tw/cgi-bin/squidGuard.cgi?clientaddr=163.22.9.25&clientname=ip025.puli09.ncnu.edu.tw&clientuser=&clientgroup=general-clients&targetgroup=moe&url=http://gatorcme.gator.com/gatorcme/autoupdate/installdatemanager.exe
> 163.22.3.7 2003/06/28 0011:00:43 PASSED
> http://163.22.3.3/gatorcme/autoupdate/installdatemanager.exe
> 218.172.162.134 2003/06/28 0011:00:44 PASSED
> http://liveupdate.symantecliveupdate.com/autoupdt.trg
> 218.172.162.134 2003/06/28 0011:00:44 PASSED
> http://202.239.172.95/autoupdt.trg
>
> [...]
> i want to find ip(163.22.3.7 218.172.162.134 ...) that are not exist in
> mysql.
There are two solutions here; The first is to read all the existing IP
addresses into a hash and check each one. The second one if to let MySQL
take care of the uniqueness of the IP address field (ie. setting that
field/column to unique in MySQL). The latter is probably the fastest (and
best way);
my %ip_addresses;
while ( <DATA> ) {
if ( /^(.*?)\s+/ ) {
$ip_addresses{$1}++;
}
}
my $stInsert = $dbh->prepare( 'INSERT INTO ip_addresses (ip_address) VALUES (?)' );
foreach ( keys %ip_addresses ) {
$stInsert->execute( $_ );
}
$stInsert->finish();
-- Tore Aursand <tore@aursand.no> "Writing is a lot like sex. At first you do it because you like it. Then you find yourself doing it for a few close friends and people you like. But if you're any good at all, you end up doing it for money." -- Unknown
- Next message: Tore Aursand: "Re: Regular Expressions Question"
- Previous message: Matt Garrish: "Re: Can somebody please help me"
- In reply to: news.hinet.net: "Re: HOW TO PARSE A VAST FILE!"
- Next in thread: Matthew Braid: "Re: HOW TO PARSE A VAST FILE!"
- Reply: Matthew Braid: "Re: HOW TO PARSE A VAST FILE!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|