in reply to Make unique hash of arrays?

use v5.12; use warnings; my %seen; local $/="//\n"; while ( my $chunk = <DATA> ) { my @lines = split/\n/, $chunk; print $chunk unless $seen{ $lines[1] }{ $lines[2] }++ } __DATA__ nick AAAAAAAAAA BBBBBBBBBB // george EGRGERHTETEHTHR VFRTTHTRRHTE // andreas AAAAAAAAAA BBBBBBBBBB // thomas EWTRYTUYJTHT CEWWEQRWT$G // peter EGRGERHTETEHTHR VFRTTHTRRHTE //

-->

nick AAAAAAAAAA BBBBBBBBBB // george EGRGERHTETEHTHR VFRTTHTRRHTE // thomas EWTRYTUYJTHT CEWWEQRWT$G //

Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Make unique hash of arrays?
by Anonymous Monk on Oct 23, 2022 at 22:02 UTC
    Thank you!! What kind of structure is this if I may ask?
      > What kind of structure is this if I may ask?

      %seen is a Hash of Hashes, see perldsc#HASHES-OF-HASHES

      Cheers Rolf
      (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
      Wikisyntax for the Monastery

      update

      dump of \%seen (which could also be named %count :)

      { AAAAAAAAAA => { BBBBBBBBBB => 2 }, EGRGERHTETEHTHR => { VFRTTHTRRHTE => 2 }, EWTRYTUYJTHT => { "CEWWEQRWT\$G" => 1 }, }
        Thank you very much for the help!