Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: deleting lines from file

by phenom (Chaplain)
on Mar 18, 2004 at 02:42 UTC ( #337590=note: print w/ replies, xml ) Need Help??


in reply to deleting lines from file

Not tested, but how about:

#!/usr/bin/perl use strict; use warnings; my $valueToDelete = $ARGV[0] || "two 222 sld"; open(FH, "oldfile") or die "open failed: $!"; my @contents = <FH>; close(FH); open(FH, ">oldfile") or die "open failed: $!"; foreach my $line (@contents) { print FH $line if($line !~ /$valueToDelete/); } close(FH);


Comment on Re: deleting lines from file
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2015-07-28 15:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (257 votes), past polls