in reply to string occurences
You would invoke at the command line as ./foo.pl < sorted.file > file.count# Untested my $current = ''; my $count = 0; while (<>) { if ( ($current ne $_) && ($current ne '') ) { print "$current :: $count \n"; $count = 0; $current = $_; } else { $count++; } }
Since the file is already sorted for you and contains only the URL, all of each URL will be grouped together. Therefor, once a URL changes you will know that you are done counting a particular URL. No need to store in memory any more than the current URL and the current count; Once the URL changes you dump out the count and move on to the next one.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: string occurences
by runrig (Abbot) on Jun 12, 2001 at 22:06 UTC | |
by Sifmole (Chaplain) on Jun 12, 2001 at 22:19 UTC | |
|
Re: Re: string occurences
by Anonymous Monk on Jun 13, 2001 at 00:00 UTC |