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

Re: Delete specific lines from txt file.

by NetWallah (Abbot)
on Aug 07, 2012 at 03:38 UTC ( #985868=note: print w/replies, xml ) Need Help??

in reply to Delete specific lines from txt file.

Here is the (untested) rest of your program.

Please reference the perl documentation for constructs you have trouble with.

$/="\n\n"; # Set the record separator to be 2 newli +nes my $sportfile=""; # Or whatever the file name is open (my $sport, "<", $sportfile) or die "Cannot open $sportfile : $!" +; while (defined <$sport>){ next if m/\b$first_name\b.+$last_name\b/; print; } close $sport;
Output will print to STDOUT. This can be directed to a file.
Update:Corrected "close $sportfile" to "close $sport;"

             I hope life isn't a big joke, because I don't get it.

Replies are listed 'Best First'.
Re^2: Delete specific lines from txt file.
by MidLifeXis (Monsignor) on Aug 07, 2012 at 12:38 UTC

    This can be directed to a file.
    Just don't redirect it to the original file name. The first thing the OS would do is to truncate the original file, leaving no data for your text file to work with.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985868]
[Corion]: Discipulus: I've looked for something but never found anything good
Corion looks at the SVG. If the different regions have IDs, then you can colorize the map by providing a CSS file with the colors.
[Corion]: Meh. IE crashes when displaying that SVG as saved from Firefox ...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2017-03-23 09:28 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (285 votes). Check out past polls.