Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^8: Get just the unique value

by Anonymous Monk
on Apr 05, 2013 at 18:59 UTC ( #1027200=note: print w/replies, xml ) Need Help??


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

Sure, the end result is that $data only holds the unique values: From this:
my $data = [ { 'type' => 'Paper' }, { 'type' => 'Paper' }, { 'type' => 'Plastic' }, { 'type' => 'Plastic' }, { 'type' => 'Plastic' }, { 'type' => 'Plastic' }, { 'type' => 'Cotton' }, { 'type' => 'Cotton' }, { 'type' => 'Cotton' }, { 'type' => 'Cotton' }, { 'type' => 'Cotton' }, { 'type' => 'Paper' }, { 'type' => 'Paper' }, { 'type' => 'Paper' }, { 'type' => 'Paper' }, { 'type' => 'Paper' }, ];
To that:
$data = [ { 'type' => 'Paper' }, { 'type' => 'Plastic' }, { 'type' => 'Cotton' }, ];

Replies are listed 'Best First'.
Re^9: Get just the unique value
by CountOrlok (Friar) on Apr 05, 2013 at 19:02 UTC
    hdb's code does exactly that, albeit sorted.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027200]
help
Chatterbox?
[SwaJime]: Ran into an interesting piece of code today ...
[SwaJime]: select name,status, status2 from __ where status & status < 13 and status2 & 16 <> 16
[SwaJime]: I'm thinking that looks messed up. Sorry for OT ... but I know y'all are smart :-)
[SwaJime]: I expected items to not be selected if status was 0 ... but they were selected
[SwaJime]: any thoughts?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-08-22 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (338 votes). Check out past polls.

    Notices?