Hello Bart and Detlef,

Thank you for your replies.  Yes, that was the solution.  I was so silly 
that I didn't think about the duplicated numbers of the initial list...

Thank you so much!

>On Mon, 4 Feb 2002 11:30:08 +0900, Nobumi Iyanaga wrote:
>
> >If, for example I hava a list of page numbers like this:
> >
> >(343, 512, 71, 562, 346, 345, 513, 561, 563, 343, 513, 549, 562, 71, 76,
> >345, 510, 563)
>
>I've been wondering about this. How on earth did you get to this list?

In fact, I am working with Nisus Writer, and my indices are already made. 
But for many entries, I have to merge them: I mean, say that I have entries 
like these:

dog     343, 512, 562...
cat     345, 512, 561...

and I have to make an entry:

animal  343, 345, 512, 561-562,

etc...

>I'm in the same line of business, and the way I'd do it, is:
>
>       # foreach $keyword, $page pair:
>           $index{$keyword}{$page}++;
>       # end foreach pair
>
>and thus, to get a proper list for each keyword, I just need to do:
>
>       my $string = join ', ', sort { $a <=> $b }
>           keys %{$index{$keyword}};
>
>(The hash values don't matter.)
>
>As you can see: no duplicates.
>
>My guess is that you started out with a push() onto an array, per page.
>

To work in this way with Perl, I guess that your text must be in a pure 
text file, on which page numbers are marked in some markup system, like:

<page1>
blah blah blah dog blah blah
</page1>
<page2>
blah blah cat blah blah blah
</page2>

I would be interested to know how you mark the words you want to put in the 
index...?

Thank you again for your help.  I am deeply grateful!

Best regards,

Nobumi Iyanaga
Tokyo,
Japan

Reply via email to