Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: filter array based on 2 fields

by hbm (Hermit)
on Aug 20, 2012 at 14:30 UTC ( #988456=note: print w/ replies, xml ) Need Help??


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


Comment on Re^2: filter array based on 2 fields
Select or Download Code
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988456]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2015-07-08 04:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls