/[informatika.old]/fill.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /fill.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dpavlin, Wed Apr 12 08:11:45 2000 UTC revision 1.3 by dpavlin, Fri Jan 25 14:47:43 2002 UTC
# Line 10  $type=~s/\.[^\.]+//g; Line 10  $type=~s/\.[^\.]+//g;
10    
11  #---  #---
12    
13  my $mydbh = DBI->connect("DBI:Pg:dbname=informatika","","") || die $DBI::errstr;  my $dbh = DBI->connect("DBI:Pg:dbname=informatika","","") || die $DBI::errstr;
14  open(IN,"< $file") || die "ne mogu otvoriti $file";  open(IN,"< $file") || die "ne mogu otvoriti $file";
15  while (<IN>) {  while (<IN>) {
16          chomp;          chomp;
# Line 42  while (<IN>) { Line 42  while (<IN>) {
42                  $sql_insert="insert into tipovi_racunala (tip) values ('$arr[0]') ";                  $sql_insert="insert into tipovi_racunala (tip) values ('$arr[0]') ";
43          } elsif ($type eq "statusi") {          } elsif ($type eq "statusi") {
44                  $sql_insert="insert into status_tip (opis) values ('$arr[0]') ";                  $sql_insert="insert into status_tip (opis) values ('$arr[0]') ";
45            } elsif ($type eq "kontakt_osobe_ic") {
46                    @foo = ( 'a'..'k', 'm'..'z', '2'..'9', 'A'..'H', 'J'..'N',
47                            'P'..'Z', '!', '#', '$', '%', '&', '(', ')', '=',
48                            '-', '/', '?' );
49                    srand;
50                    $passwd="";
51                    for (1..8) {
52                            $ch=$foo[int(rand($#foo))];
53                            $passwd=$passwd.$ch;
54                    }
55                    $sql_insert="insert into kontakt_osobe (ime,prezime,e_mail,passwd,prava) values ('$arr[0]','$arr[1]','$arr[2]','$passwd',64) ";
56            } elsif ($type eq "sap2informatika") {
57                    next if ($arr[2] eq "");
58                    $sql_insert="insert into sap2orgjed values ('$arr[0]','$arr[1]','$arr[2]')";
59          } else {          } else {
60                  die "Nepoznat tip datoteke $type !!";                  die "Nepoznat tip datoteke $type !!";
61          }          }
62    
63          print "--$sql_insert\n";          print "--$sql_insert\n";
64          $mydbh->do("$sql_insert") || die $mydbh->errstr();          $dbh->do("$sql_insert") || die $dbh->errstr();
65    
66  }  }
67    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.26