in reply to Printing Categories from SQL search
One option in deduplication is usually a hash:
my %cats; while (my $pointer = $sth->fetchrow_hashref) { $cats{$pointer->{category}} = 1; } for my $category (keys %cats) { print "$category\n"; }
See also the FAQ How can I remove duplicate elements from a list or array?
Update: typo now fixed (line 3 was $cat{...}). Thanks wjw for spotting.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Printing Categories from SQL search
by htmanning (Friar) on Sep 27, 2018 at 00:08 UTC | |
by kcott (Archbishop) on Sep 27, 2018 at 08:14 UTC | |
by hippo (Archbishop) on Sep 27, 2018 at 08:07 UTC | |
by wjw (Priest) on Sep 27, 2018 at 00:20 UTC |