Mertens Bram wrote:
> Hi,
>
> I have a bookmark-file from opera6.11 that contains a lot of duplicate
> entries.
>
> I would like to be able to remove all duplicate entries without
> destroying the structure of the file.

This is something that you could do to any level of complexity. First of
all, hashes are good for finding duplicates. I would scan the file for
all 'URL=' lines and increment the value of a hash keyed on that URL.
For instance:

    my %urls;
    open BMK, "< Opera6.adr" or die "Unable to open bookmarks: $!";
    while (<BMK>)
    {
        chomp;
        next unless /URL=(.+)/;
        $urls{$1}++;
    }
    close BMK;

    foreach (sort keys %urls) { print "$_\n" if $urls{$_} > 1 };

Which will list all of the URLs which occur more than once. You can use
this list to edit the file manually, or you may want to go on to improve
the script to where it will digest the entire file and generate a new
one.

Get it working this far first!

Cheers,

Rob




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

Reply via email to