http://www.perlmonks.org?node_id=988456


in reply to Re: filter array based on 2 fields
in thread filter array based on 2 fields

More simply - and keeping the order:

@arr = ('c1,s1,d1','c2,s2,d2','c1,s1,d2','c1,s2,d3'); @arr = grep{ /(.+),/; !$seen{$1}++ } @arr; print join$/,@arr;

Prints:

c1,s1,d1 c2,s2,d2 c1,s2,d3

Replies are listed 'Best First'.
Re^3: filter array based on 2 fields
by Anonymous Monk on Aug 20, 2012 at 17:40 UTC
    Hi it's an array like this (client,Status,Description client,Status,Description and so on) it's lines for a csv file I need to remove duplicates based on client and status as description can vary because of a timestamp Thanks Thorbjorn

      Hi
      it's an array like this
      (client,Status,Description
      client,Status,Description
      and so on)
      it's lines for a csv file I need to remove duplicates based on client and status as description can vary because of a timestamp
      Thanks Thorbjorn