/[informatika.old]/sap.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

Annotation of /sap.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Fri Jan 25 14:47:43 2002 UTC (22 years, 2 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
File MIME type: text/plain
sap organizacijske jedinice

1 dpavlin 1.1 #!/usr/bin/perl -w
2     use 5.005;
3     use strict;
4    
5     use lib "/home/dpavlin/informatika/odbc";
6     use ODBCSocketServer::IO; #declare the ODBC Socket Server package
7    
8     my ($result,$ime,$prezime,$sifra);
9    
10     my $debug=0;
11    
12     die "Usage: $0 [ime|prezime|sifra]" if (! @ARGV);
13    
14     my ($foo) = $ARGV[0];
15    
16     my $sql="select IDKorisnika,Prezime,Ime from korisnik where ";
17    
18     if ($foo =~ /^(\d+)$/) {
19     $sql.="IDKorisnika = $1";
20     } else {
21     $sql.="Ime like '".uc($foo)."%' or Prezime like '".uc($foo)."%'";
22     }
23    
24     print STDERR "$sql\n" if ($debug);
25    
26     $result = ODBCSocketServer::IO::ExecSQL("tkcpdc.pliva.hr",
27     "dsn=imenik;uid=admin;pwd=admin","$sql");
28    
29     sub initcap {
30     my ($str) = $_[0];
31     $str=~tr/šðžèæŠÐŽÈÆ/¹ð¾èæ©Ð®ÈÆ/; # 1250 -> iso8859-2
32     my ($lower,$upper);
33     $lower=$upper=$str;
34     $lower=~tr/[A-Z]©ÐÈÆ®/[a-z]¹ðèæ¾/;
35     my $new;
36     for (my $i=0; $i<length($lower); $i++) {
37     my $cl=substr($lower,$i,1);
38     my $cu=substr($upper,$i,1);
39     if ($i==0) {
40     $new.=$cu;
41 dpavlin 1.2 } elsif ($cl =~ / \.-/) {
42 dpavlin 1.1 $i++;
43     $new.=$cl.substr($upper,$i,1);
44     } else {
45     $new.=$cl;
46     }
47     }
48     return($new);
49     }
50    
51     print STDERR "$result\n" if ($debug);
52    
53     my @lines=split(/[\n\r]+/,$result);
54     my $nl=0;
55     my @arr;
56     foreach (@lines) {
57     s/<[^>]+>//g;
58     if ($_ ne "") {
59     push @arr,initcap($_);
60     $nl=1;
61     } elsif ($nl == 1) {
62     print join("\t",@arr),"\n";
63     undef @arr;
64     $nl=0;
65     }
66     }
67    

  ViewVC Help
Powered by ViewVC 1.1.26