I've already learnt how to remove duplicates in Perl using the following code:
my %seen = ();
my @unique = grep { ! $seen{ $_}++ } @array;
But what about if I want to merge the overlapping parts? Is there a simple way like the above code to directly do the job?
For example a bit of the input file looks something like this:
Anais Nin : People living deeply have no fear of death. Pascal : Wisdome sends us back to our childhood. Nietzsche : No one lies so boldly as the man who is indignant. Camus : Stupidity has a knack of getting its way. Plato : A good decision is based on knowledge and not on numbers. Anais Nin : We don't see things as they are, we see them as we are. Erich Fromm : Creativity requires the courage to let go of certainties. M. Scott Peck : Share our similarities, celebrate our differences. Freud : The ego is not master in its own house. Camus : You cannot create experience. You must undergo it. Stendhal : Pleasure is often spoiled by describing it.
The desire output looks like this:
Anais Nin : People living deeply have no fear of death. We don't see things as they are, we see them as we are. Pascal : Wisdome sends us back to our childhood. Nietzsche : No one lies so boldly as the man who is indignant. Camus : Stupidity has a knack of getting its way. You cannot create experience. You must undergo it. Plato : A good decision is based on knowledge and not on numbers. Erich Fromm : Creativity requires the courage to let go of certainties. M. Scott Peck : Share our similarities, celebrate our differences. Freud : The ego is not master in its own house. Stendhal : Pleasure is often spoiled by describing it.
Thanks, as always, for any guidance !