Txt file: Delete line - Delete line from txt file
Hi-
I need to be able to delete a line of text from a file when it meets certain search criteria...like if they say "stock", the line of text with "stock" in it gets deleted. Any ideas how to do this with Perl? Thanks!
----------
Casey Hansen
www.caseynet.com
Fazer84 posted this at 03:38 — 6th August 1999.
They have: 62 posts
Joined: May 1999
Hi-
Could you please give me the full code to do this? (I am still kind of new to PERL) THANKS!
----------
Casey Hansen
www.caseynet.com
Ted S posted this at 20:14 — 6th August 1999.
They have: 92 posts
Joined: May 1999
open(USERS,"./dc/users.txt" ) ;
@users=<USERS>;
close(USERS);
open(USERS,">./dc/users.txt" ) ¦¦ &error("Unable to write to ./dc/users.txt" ) ;
foreach $line (@users) {
# PLACE CRITERIA HERE
unless ($X eq $Y) {
print USERS $line;
}
}
close(USERS);
----------
Ted Sindzinski
www.infinityinternet.com www.solutionscripts.com
<<edited by Patrick Baer, to take out the smileys>>
Ted S
Fazer84 posted this at 03:20 — 7th August 1999.
They have: 62 posts
Joined: May 1999
Hi-
What do I place in the CRITERIA comment spot? Remember, I'm a newbie
----------
Casey Hansen
www.caseynet.com
anti posted this at 04:05 — 17th August 1999.
They have: 453 posts
Joined: Jan 1999
Hi,
change the
unless($X eq $Y){
to
unless($line =~ /stock/){
and you have what you wanted.
ciao
Anti
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.