Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: removing duplicate entries from an array

by kirbyk (Friar)
on Nov 07, 2005 at 20:51 UTC ( #506523=note: print w/replies, xml ) Need Help??


in reply to removing duplicate entries from an array

Quick and dirty? How about:
my %seen; my @ABC; for my $element (@XYZ) { next if $seen{$element}++; push @ABC, $element; } @XYZ = @ABC;
Of course, it's a huge waste to create the second array for a placeholder (even though that code is very easy to understand.) You probably want to delete the entries in place, using splice or array slices, if the array can possibly be of any length.

-- Kirby, WhitePages.com

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://506523]
help
Chatterbox?
[Corion]: Meh. IE crashes when displaying that SVG as saved from Firefox ...
LanX blame Canada!
[Discipulus]: to crash is not the default behaviour of IE? ;=)
[Discipulus]: so every library (js) to sdelect and modify the id parameters can be good.
[Discipulus]: I never understood something: I can on the fly modify the XML structure of the SVG using for example XML::Twig ?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2017-03-23 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.