Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Detecting duplicate keywords passed in a form

by JayBonci (Curate)
on Mar 22, 2003 at 10:33 UTC ( #245120=note: print w/ replies, xml ) Need Help??


in reply to Detecting duplicate keywords passed in a form

Keeping order (but only keeping the last seen element of a string):

#!/usr/bin/perl -w use strict; my ($i, $keywords, @finalwords); %$keywords = map { lc($_) => $i++} qw/foo bar bat hello foo HELLO/; print join " ", @finalwords = sort {$keywords->{$a} <=> $keywords->{$b +}} keys %$keywords;
My comment here is that you can use the hash's value to preserve order as well. Comments welcome.

    --jaybonci


Comment on Re: Detecting duplicate keywords passed in a form
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://245120]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2015-08-01 01:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls