Edit a Flatfile Database

They have: 40 posts

Joined: Oct 2001

Hello,

If I have a flatfile text database, with any number of lines, each with a fixed number of fields, can I easily edit it using perl?

I've worked out how to check each line to match some variable, and then delete, but I need to check for a match, and then bring the details onto the browser, so the user can both edit, and then resubmit back to the database. I need it so it doesn't duplicate lines, or doesn't have 2 almost the same lines with one field different.

The data arrives in the database originally from a form. So if possible, I'd like to give it back to the user in a form, so he can edit and then submit.

Any ideas?

merlin's picture

They have: 410 posts

Joined: Oct 1999

i recently wrote some code for doing exactly that kind of stuff...
i'll post the code in here by tomorrow.

They have: 40 posts

Joined: Oct 2001

Looking forward to it!

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I'm assuming Perl... Is that right?

They have: 40 posts

Joined: Oct 2001

Yep...

merlin's picture

They have: 410 posts

Joined: Oct 1999

http://www.kdive.ch/twf/

there are four files:
ticker.pl - there you (and anyone you want to) can add new entries to the file
setticker.pl - there the admin can change the entries
index.pl - that's the file i need to show the entries to anyone
ticker.pm - some variables

all the stuff is saved in a file called 'tickerdaten.txt', everytime you change anything there's made a backup copy 'tickerdaten_date_seconds.txt' in a subdirectory.

i need all the stuff for my frontpage. i show the news of our company with it. that's why there are two main categories: ticker and so called 'bildboxen'. ticker only contain text, bildboxen contain an image, title and some text. if you wanna use it all you'll need some template-files (for showing all the html-stuff around the data).

everything's in german, but i guess you're able to handle it with playing around with it.

i know it's not THAT clean coded, but it's my first thing with this size...

They have: 40 posts

Joined: Oct 2001

Hey Merlin,

Thanks for going to this trouble...

I went to the page you set up, and downloaded the first 3 files. The 4th one wasn't there. I've had a look at the 3 files I got, and I'll be honest, I'm struggling!!!

Mainly because your site and some parts of the scripts are in German. I know it shouldn't throw me, but it does! I think because it's in a language I don't understand. I have to really concentrate to understand most perl scripts, but this seems to be making it really difficult for me. Probably most other perlers, who have been coding for longer than I have (a month!) would be able to grasp this no problem.

So, I'll keep playing around with what I initially tried, unless others have some ideas.

Thanks again...

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.