in reply to Delete specific lines from txt file.
Here is the (untested) rest of your program.
Update:Corrected "close $sportfile" to "close $sport;"
Please reference the perl documentation for constructs you have trouble with.
Output will print to STDOUT. This can be directed to a file.$/="\n\n"; # Set the record separator to be 2 newli +nes my $sportfile="my.sport.txt"; # 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;
Update:Corrected "close $sportfile" to "close $sport;"
I hope life isn't a big joke, because I don't get it.
-SNL
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Delete specific lines from txt file.
by MidLifeXis (Monsignor) on Aug 07, 2012 at 12:38 UTC |
In Section
Seekers of Perl Wisdom