Я уже научился удалять дубликаты в Perl, используя следующий код:
my %seen = ();
my @unique = grep { ! $seen{ $_}++ } @array;
Но что если я захочу объединить перекрывающиеся части? Есть ли простой способ, как в приведенном выше коде, напрямую выполнять работу?
Например, немного входного файла выглядит примерно так:
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.
Выход желания выглядит так:
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.
Спасибо, как всегда, за любое руководство!