Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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
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 lurking in the Monastery: (9)
As of 2014-12-19 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (82 votes), past polls