Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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.
Re^3: Delete specific lines from txt file.
by roboticus (Canon) 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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2014-12-27 18:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls