Leser: 26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
my @list = ( 'Tomate', 'Kartoffel', 'Kartoffel', 'Tomate', 'rote Paprika', 'Blumenkohl', 'Tomate', ); my %seen; $seen{$_}++ for @list; my @single = grep{ $seen{$_} == 1 }keys %seen; print $_,"\n" for @single;
my @single = grep{ $seen{$_} == 1 }map{ $seen{$_}++; $_ }@list;
my @seen = keys %{ { map{ $_ => 1 } @list } };
1 2 3 4 5 6 7 8 9 10 11 12
use List::MoreUtils qw/uniq/; my @list = qw/ Tomate Kartoffel Kartoffel Tomate rote Paprika Blumenkohl Tomate /; my @uniq = uniq @list;
2009-08-19T16:04:12 MatthiasWDas ist aber doch gar nicht was er möchte ;)
1 2 3 4 5 6 7 8 9 10 11 12 13
use Array::Uniq; my @list = qw/ Tomate Kartoffel Kartoffel Tomate rote Paprika Blumenkohl Tomate /; print join("\n", distinct(sort(@list))), "\n";
Kirsche Tomate Tomate Kartoffel Paprika Blumenkohl Tomate
Kirsche Kartoffel Paprika Blumenkohl Tomate
my @single = grep{ $seen{$_} == 1 }keys %seen;
1 2 3 4
my %seen; $seen{$_}++ for @list; my @single = grep{ $seen{$_} == 1 }keys %seen;