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; |
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 |
|
|