--- fill.pl 2000/04/12 08:11:45 1.1 +++ fill.pl 2002/01/25 14:47:43 1.3 @@ -10,7 +10,7 @@ #--- -my $mydbh = DBI->connect("DBI:Pg:dbname=informatika","","") || die $DBI::errstr; +my $dbh = DBI->connect("DBI:Pg:dbname=informatika","","") || die $DBI::errstr; open(IN,"< $file") || die "ne mogu otvoriti $file"; while () { chomp; @@ -42,12 +42,26 @@ $sql_insert="insert into tipovi_racunala (tip) values ('$arr[0]') "; } elsif ($type eq "statusi") { $sql_insert="insert into status_tip (opis) values ('$arr[0]') "; + } elsif ($type eq "kontakt_osobe_ic") { + @foo = ( 'a'..'k', 'm'..'z', '2'..'9', 'A'..'H', 'J'..'N', + 'P'..'Z', '!', '#', '$', '%', '&', '(', ')', '=', + '-', '/', '?' ); + srand; + $passwd=""; + for (1..8) { + $ch=$foo[int(rand($#foo))]; + $passwd=$passwd.$ch; + } + $sql_insert="insert into kontakt_osobe (ime,prezime,e_mail,passwd,prava) values ('$arr[0]','$arr[1]','$arr[2]','$passwd',64) "; + } elsif ($type eq "sap2informatika") { + next if ($arr[2] eq ""); + $sql_insert="insert into sap2orgjed values ('$arr[0]','$arr[1]','$arr[2]')"; } else { die "Nepoznat tip datoteke $type !!"; } print "--$sql_insert\n"; - $mydbh->do("$sql_insert") || die $mydbh->errstr(); + $dbh->do("$sql_insert") || die $dbh->errstr(); }