Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Delete Duplicate Entry in a text file

by sauoq (Abbot)
on Jun 20, 2012 at 02:41 UTC ( #977203=note: print w/replies, xml ) Need Help??


in reply to Delete Duplicate Entry in a text file

Assuming you've opened $fh for reading on your fail.txt file or whatever, it should be about as easy as....

my $last; while (my $line = <$fh>) { next if defined $last and $line eq $last; print $line; $last = $line; }
You'll have to modify it a bit for those blank lines, if they really appear in your log files.

Edit: added my $line = to while loop.

-sauoq
"My two cents aren't worth a dime.";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://977203]
help
Chatterbox?
[Discipulus]: good morning marto
[Discipulus]: if i can ask: which is the minimal (cheapest) configuration to have some hardware running a webserver with minimal traffic and wifi connection?
[marto]: Raspberry Pi 3?
[Discipulus]: thanks under 50 neuros it's a good thing!

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2017-10-17 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (225 votes). Check out past polls.

    Notices?