Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Unique array w/o repeated elements and still keep the original order!

by tstock (Curate)
on Aug 09, 2002 at 19:10 UTC ( [id://189007]=note: print w/replies, xml ) Need Help??


in reply to Unique array w/o repeated elements and still keep the original order!

foreach my $instance (@lines2) { print OUTF $instance unless $hsh{$instance}++; }
Tiago
Update: replaced 'if' with 'unless'. thanks robobunny
  • Comment on Re: Unique array w/o repeated elements and still keep the original order!
  • Download Code

Replies are listed 'Best First'.
Re: Re: Unique array w/o repeated elements and still keep the original order!
by robobunny (Friar) on Aug 09, 2002 at 19:50 UTC
    i'm assuming it was just a typo, but i think you meant:
    foreach my $instance (@lines2) { print OUTF $instance unless $hsh{$instance}++; }
    as written, it will only print the duplicates.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-25 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found