in reply to Re: Duplicated data in array.
in thread Duplicated data in array.

Would this be possible to be stored in reference? Getting confused with the data type.
my %seen1; my $out1 = grep { ! $seen1{ $_->{ID} }++ } @in; pp @{ $out1 };

Replies are listed 'Best First'.
Re^3: Duplicated data in array. (updated)
by AnomalousMonk (Archbishop) on Nov 02, 2021 at 20:27 UTC

    Untested:

    my %seen1; my @out1 = grep { ! $seen1{ $_->{ID} }++ } @in; my $arrayref = \@out1; pp $arrayref;

    Update: Perhaps a bit late for this afterthought, but the general form of this question is "How do I create a reference to X?" Please see perlref and perlreftut. See also Perl Data Structures Cookbook (perldsc) for dealing with complicated referential structures.


    Give a man a fish:  <%-{-{-{-<

Re^3: Duplicated data in array.
by LanX (Saint) on Nov 02, 2021 at 20:35 UTC