Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Removing repeated lines from file

by Anonymous Monk
on Jun 25, 2003 at 19:29 UTC ( [id://268966]=note: print w/replies, xml ) Need Help??


in reply to Removing repeated lines from file

PUT EACH LINE IN A HASH, IT'LL ELIM DUPES FOR YOU AUTOMATICALLY.
open(INFH, "<filename.txt"); my @data=<INFH>; close(INFH); open(OUTFH, ">outfile.txt"); my %hashdata = (); foreach my $thisline (@data) { $hashdata{$thisline} = 1; } foreach my $thisline (sort(keys(%hashdata))) { print(OUTFH, $thisline) } close(OUTFH);

Log In?
Username:
Password:

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

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

    No recent polls found