Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^7: Get just the unique value

by hdb (Prior)
on Apr 05, 2013 at 19:34 UTC ( #1027206=note: print w/replies, xml ) Need Help??


in reply to Re^6: Get just the unique value
in thread Get just the unique value

How about this?

my %types; my $res; foreach my $entry (@$data) { push @$res, $entry unless $types{$entry->{"type"}}++; } print Dumper $res;

Replies are listed 'Best First'.
Re^8: Get just the unique value
by hdb (Prior) on Apr 05, 2013 at 19:43 UTC

    Or this without helper hash?

    my $res; foreach my $entry (@$data) { push @$res, $entry unless grep { $_->{"type"} eq $entry->{"type"} +} @$res; } print Dumper $res;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027206]
help
Chatterbox?
[choroba]: What is infobot
[choroba]: infobot is an irc bot that "learns" by remembering sentences of the form "X is Y" and then replying to "What is X" with "X is Y"
[choroba]: it works!
[Corion]: choroba: :-D
[Corion]: And yes, at least the basic implementation is to strip off some prepositions ("the", "a", "an") from the term with regular expressions and then do a regex match ;-)
[Corion]: So that could become a fun series of articles that implement this with regular expressions, Parse::Eyapp, Marpa, YACC, Perl6 and Regexp::Grammar and whatnot. If I have a test suite, I could even do benchmarks.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2017-08-17 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (286 votes). Check out past polls.

    Notices?