CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
flat file db help..simple question?

 



ARSONe
Deleted

Dec 5, 2000, 7:49 PM

Post #1 of 2 (426 views)
flat file db help..simple question? Can't Post

lol i think this is kind of a newbie question but i didnt think it was newbie enough for the begginer section.

I have a flat file db, I want to delete a specific line of the flat file db.. what would be the code for this?

------------
-----example
------------
style: 3 fields, id,name,url split by the | character.

1|JOHN|http://johnsurl.com
2|ARSONE|http://arsone.com
3|SOMEONES_NAME|http://a-site.net

lets just say i want to delete id #2 (2|ARSONE|http://arsone.com) how would i delete that whole line. Thanks for taking the time to read.


(A)


sleuth
Enthusiast / Moderator

Dec 5, 2000, 8:40 PM

Post #2 of 2 (426 views)
Re: flat file db help..simple question? [In reply to] Can't Post

 
Def an intermediate question, :)

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


open(file, "<data.db") &#0124; &#0124; print "$!";
while(<file){
($id,$name,$url)=split(/\|/, $_);
if ($name ne "ARSONE"){
push(@new,$_);
}
}
close(file);
open(file_new, ">data.db") &#0124; &#0124; print "$!";
print file_new @new;
close(file_new);
</pre><HR></BLOCKQUOTE>

Sleuth

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives