Database program

They have: 568 posts

Joined: Nov 1999

I got a little bored so I made a nifty database program that may come in handy to some of you. I'll put it up on my web site once the design is finished.

code:

$del = "\t";
$data_file = "data.txt";

open(file,$data_file);
@file = <file>;
close(file);

$header = shift(@file);
chop($header);

@headers = split($del,$header);

foreach (@file) {
	chop;
	$y = 0;
	
	@line = split($del,$_);
	foreach $arg (@line) {
		if($y == 0) {
			$side = $arg;
			$y++;
		} else {
			${$side}{$headers[$y]} = "$arg";
			$y++;
		}
	}
}[/code]

It's pretty simple and reads flat text databases that are organized like SQL tables. An example database would look like.

code:
name	one	two	three	four
brandon	1a	2a	3a	4a
john	1b	2b	3b	4b
alex	1c	2c	3c	4c[/code]

If you wanted to see the value of Brandon and one you'd type $brandon{'one'} and you'd get 1a.

I know, it's not very complicated but it gets the job done. 

Comments?



[This message has been edited by Orpheus (edited 12 May 2000).]