Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://337590]
[Your Mother]: Das right.
[Eily]: actually I forgot to provide the filename as a parameter
LanX it reeks.
[Your Mother]: You know what they say, the reeky wheel gets the best price at cheese market.
[Eily]: well I had to google translate that
[Eily]: let me inform you that the Dutch reek translate into the Czech páchnout
[Eily]: very useful default translation :P
[Eily]: BTW LanX, you should try typing a few random chars at the beginning of each message. This will prevent expansion :P
[LanX]: qwiud you sthink so?
[LanX]: zxwqbd good idea! :)

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2017-03-27 16:48 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.