![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programmer
Join Date: Nov 2007
Posts: 74
Rep Power: 1
![]() |
Re: Count number of occourences of a IP address in a log file.
perl Syntax (Toggle Plain Text)
$ time cat ipaddr.txt | perl count.pl > report.txt real 4m9.138s user 3m7.281s sys 0m58.301s perl Syntax (Toggle Plain Text)
$ time cat ipaddr.txt | perl hashcount.pl > report.txt real 0m0.501s user 0m0.433s sys 0m0.052s |
|
|
|
|
|
#12 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,722
Rep Power: 5
![]() |
Re: Count number of occourences of a IP address in a log file.
Hah, I can't believe Perl can actually do that in a matter of minutes. But it's still pretty clear that the associative array takes the cake with half a second.
Thanks for that demo. Cheers. |
|
|
|
|
|
#13 |
|
Newbie
Join Date: Dec 2007
Posts: 4
Rep Power: 0
![]() |
Re: Count number of occourences of a IP address in a log file.
Hey guy's,
Glad your all debating how to do this.. I have NO idea what that code does so could anyone clarify what i need to do to achieve my goal hehe. Thanks again. Graham |
|
|
|
|
|
#14 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,722
Rep Power: 5
![]() |
Re: Count number of occourences of a IP address in a log file.
mbd's posted code snippet outputs how many instances, of each IP address, are in the log file that Jessehk posted. I'd recommend using his second snippet (which is the psuedocode that I suggested in my first post), since it takes less than half a second to execute. If you know Perl you should be able to modify it to fit your needs.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Jumping to a specific line number in a text file | Adeil | C++ | 4 | Nov 5th, 2007 9:54 AM |
| PigLattin Converter, count number of words used in dictionary. | MrSmiley | Python | 2 | Oct 17th, 2005 4:47 PM |
| After execution - Error cannot locate /Skin File? | wchar | Visual Basic | 1 | Mar 5th, 2005 9:04 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |
| Specific file address... | Monkey_features | Delphi | 0 | Feb 8th, 2005 5:05 PM |