Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 chilling in the Monastery: (5)
As of 2014-09-22 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (208 votes), past polls