Hi,
Two years ago I got the included code to implement the External File mod made by the famous JPDENI.
Purpose : to split existing text fields records from the flat text db file into separate .txt files.
Now I want to do the reverse.
Anyone got any idea how to rewrite this code so the tekst in the sepreate .txt files will be placed in the db file again?
=code=====================================
my ($line, @data, $field);
$db_file_name = "c:/cgi-bin/dbman/default.db";
$outdir = "c:/cgi-bin/dbman/auth/";
open (DB, $db_file_name);
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
$line = $_; chomp ($line);
@data = &split_decode($line);
# Assuming you want call your files as ID.txt where ID is in field 0
$outfile = @data[0].".txt";
open (OUT, ">$outdir/$outfile");
# Assuming data you want to export are in field 3
print OUT @data[6];
close OUT;
}
close DB;
exit;
sub split_decode
{
my ($input) = shift;
$input =~ s/\Q|\E$/| /o;
my (@array) = split (/\Q|\E/o, $input);
for ($i = 0; $i <= $#array; $i++)
{
$array[$i] =~ s/~~/|/og;
$array[$i] =~ s/``/\n/g;
}
return @array;
}
=eof============================
Close Watch
LyricZ http://www.e-lyricz.com
NL
Two years ago I got the included code to implement the External File mod made by the famous JPDENI.
Purpose : to split existing text fields records from the flat text db file into separate .txt files.
Now I want to do the reverse.
Anyone got any idea how to rewrite this code so the tekst in the sepreate .txt files will be placed in the db file again?
=code=====================================
my ($line, @data, $field);
$db_file_name = "c:/cgi-bin/dbman/default.db";
$outdir = "c:/cgi-bin/dbman/auth/";
open (DB, $db_file_name);
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
$line = $_; chomp ($line);
@data = &split_decode($line);
# Assuming you want call your files as ID.txt where ID is in field 0
$outfile = @data[0].".txt";
open (OUT, ">$outdir/$outfile");
# Assuming data you want to export are in field 3
print OUT @data[6];
close OUT;
}
close DB;
exit;
sub split_decode
{
my ($input) = shift;
$input =~ s/\Q|\E$/| /o;
my (@array) = split (/\Q|\E/o, $input);
for ($i = 0; $i <= $#array; $i++)
{
$array[$i] =~ s/~~/|/og;
$array[$i] =~ s/``/\n/g;
}
return @array;
}
=eof============================
Close Watch
LyricZ http://www.e-lyricz.com
NL