Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Delete specific lines from txt file.

by FredFredFred (Initiate)
on Aug 07, 2012 at 23:15 UTC ( #986101=note: print w/replies, xml ) Need Help??


in reply to Re: Delete specific lines from txt file.
in thread Delete specific lines from txt file.

hmm, that sounds good, but I have no clue how to do it... Can you provide some code? Thanks

  • Comment on Re^2: Delete specific lines from txt file.

Replies are listed 'Best First'.
Re^3: Delete specific lines from txt file.
by roboticus (Chancellor) on Aug 09, 2012 at 21:02 UTC

    FredFredFred:

    # Discard every other line open FIN, 'INFILE' or die; open FOUT, '>INFILE.new' or die; my $cnt; while (<FIN>) { next if $cnt%2; print FOUT; } close FH; close FOUT; rename 'INFILE', 'INFILE.bak'; rename 'INFILE.new', 'INFILE;

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://986101]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2016-12-11 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (169 votes). Check out past polls.