i am getting some data from a text file. and importing that data to
create some tables; my code is below:

#! /usr/bin/perl -w
#adding contact_list for each user
use DBI;                
use strict;

print "\n\n************************************************\n";
print "Running this Script will erase the previous data\n\n";
print "\n\n************************************************\n";

my (@array,@user,@dept);
my $data_file="listuser.txt";
open(TEXT,$data_file) || die("could not open file!");
my @text=<TEXT>;

foreach  (@text){
@array=split(' ',"@text");
}  

my $w=0;
while($w<$#array){
$user[$w]=$array[$w];
$w+=2;
$dept[$w]=$array[$w];
$w++;
}

#for adding user accounts******************

my $username="root";
my $pass="12345";
my $dbname="jabberd2";

my $dbh=DBI->connect("DBI:mysql:$dbname",$username,$pass,{RaiseError
=> 1, AutoCommit => 0});
#drop table
my $drp = $dbh->do("drop table authorize");
   $drp = $dbh->do("drop table contact_list");

#create table
my $CreateTable=$dbh->prepare("create table contact_list(owner
tinytext,addmember tinytext,ownerdept tinytext,addmemberdept
tinytext)");
$CreateTable->execute();

$CreateTable=$dbh->prepare("create table authorize(user tinytext,passw
tinytext, dept tinytext)");
$CreateTable->execute();

#insert data for user account
my $im =0;
my $k=0;
my $end = $#array;
while($im < $end){
my $Insert="insert into authorize
values('$array[$im]','$array[$im+1]','$array[$im+2]')";
my $rtn = $dbh->do ($Insert);
$k=$im+2;$im=$k;$im++;
}


#insert data for contact list
my $i=0;
my $j=0;

for ($j=0;$j<$#user-1;$j++){
for ($i=0;$i<$#user;$i+=3){
my $Insert=("insert into contact_list
values('$user[$j]','$user[$i+3]','$dept[$j+2]','$dept[$i+5]')");
my $rtn = $dbh->do ($Insert);
}
}

#delete unspecified records
my $delete=$dbh->do("delete from contact_list where owner='' ");

$CreateTable->finish();
$dbh->disconnect();

these Errors are generating:
Use of uninitialized value in concatenation (.) or string at
./jabber.pl line 63, <TEXT> line 9.

any suggestion?
Thanks,
Adam

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to