,,,
6.1 Perl
6.1.1
6.2
6.2.1 Oracle
6.2.1.1
6.2.1.2
6.2.1.3
6.2.1.4
6.3 CGI
6.4 DBF
6.1 Perl
6.1.1
Perl - ,
, .
Perl .
, , ,
. Perl C,
shell, sed awk, ,
, Perl- . C
Perl- C.
UNIX
Perl ,
.
. Perl ,
.dbm ,
. Perl ,
, C++ Perl-,
, Oracle.
CGI-,
, , .
WWW.
Perl .
Oracle
.
, , .
#!/usr/local/bin/perl
use Oraperl;
# Oraperl
$system_id = 'T:bdhost.com:Base';
$lda = &ora_login($system_id,'scott','tiger');
#
$st = 'create table EMP (name varchar2(100),
organization varchar2(100))';
$csr = &ora_open($lda,$st) || die $ora_errstr;
&ora_close($csr);
#
$st = 'insert into EMP values
(\'John Smit\', \'NATO\')';
$csr = &ora_open($lda, $st);
&ora_close($csr);
#
:
Name |
Organization |
John Smit | NATO |
$st = 'select name from EMP
where organization = \'NATO\'';
$csr = &ora_open($lda,$st);
# name,
# organization
# 'NATO'
@result = &ora_fetch($csr);
# @result
&ora_close($csr);
print @result;
&ora_logoff($lda);
#
Oracle
Perl Oraperl.pm
.
:
&ora_login
$lda = &ora_login($system_id,$username,$password)
, , Oracle
. &ora_login()
.
: ,
.
(Oracle
Login Data Area
).
. OCI(Oracle Call Interface) olon
orlon
.
&ora_open
$csr = &ora_open($lda, $statement [,$cache])
SQL- &ora_open
.
: SQL
.
SELECT . Oracle
.
, .
$csr = &ora_open($lda,'select ename,
sal from emp order by ename',10);
OCI oopen
oparse
.
&ora_bind
&ora_bind($csr, $var, ...)
SQL Perl,
. &ora_bind
.
$csr = &ora_open($lda, 'insert into emp values (:1,:2)');
&ora_bind($csr,$ename,$sal);
- SQL :1
:2
$ename
$sal
.
&ora_fetch
$nfields = &ora_fetch($csr[, trunc]);
@array = &ora_fetch($csr);
SQL SELECT
-
, &ora_open
.
, - .
,
LONG
LONG RAW
. ,
$ora_trunc
.
, $ora_errno
1406.
OCI ofetch
.
&ora_close
&ora_close($csr)
,
&ora_close
.
OCI oclose
.
&ora_do
&ora_do($lda,$statement)
SQL-
. &ora_do
&ora_open
&ora_close
.
, -- SQL .
&ora_do($lda,'drop table employee');
:
&ora_close(&ora_open($lda, 'drop table employee'));
&ora_logoff
&ora_logoff($lda)
&ora_logoff
.
OCI ologoff
.
&ora_titles()
&ora_length()
&ora_types()
&ora_autocommit()
&ora_commit()
&ora_rollback()
&ora_version()
&ora_titles
@titles = &ora_titles($csr)
,
, &ora_title
.
- . .
&ora_length
@length = &ora_length($csr)
, ,
&ora_length
.
- .
&ora_types
@types = &ora_types($csr)
, ,
&ora_types
.
- .
OCI oraperl.ph
Oracle v6
.
&ora_autocommit
&ora_autocommit($lda,$on_or_off)
&ora_autocommit
.
:
, , .
, , , .
.
. ,
.
&ora_commit, &ora_rollback
&ora_commit($lda)
&ora_rollback($lda)
. - .
, &ora_rollback
.
,
.
&ora_version
&ora_version()
, Oraperl
.
.
Oraperl.pm
:
$ora_cache
$ora_long
$ora_trunc
$ora_errno
$ora_errstr
$ora_verno
Oraperl
.
$ora_cache
&ora_open()
SELECT-, .
.
, ,
.
.
$ora_long Oraperl
. LONG
LONGRAW
.
(65535 bytes
)
. &ora_open()
, LONG
,
$ora_long
.
80 ( Oracle
),
.
$ora_trunc Oraperl
LONG
, ,
$ora_long
. , &ora_fetch
, .
, $ora_trunc
.
$ora_errno
- . , &ora_fetch()
.
, LONG
LONGRAW
, , $ora_errno
1406, , .
, &ora_fetch()
false
,
$ora_errno
0 ,
.
$ora_errstr ,
$ora_errno
.
$ora_verno Oraperl
v.ppp, v -
, ppp - patchlevel.
Oraperl
SQL Perl.
. :
$csr = &ora_open($lda,"insert into tel values(:1,:2)");
:1
:2
. &ora_bind()
.
&ora_bind($csr, "Annette","3-222-2-22-22-22");
&ora_bind($csr,$name,$telephone);
1,
&ora_bind
.
Perl CGI
(Common Gateway Interface) Web. , Perl
. - Perl
CGI-.
CGI- ( POST
).
#!/usr/local/bin/perl
sub Print {
$len = 100;
$buf = "";
read(STDIN, $buf,$len);
#
# $buf
# $len
@ar = split(/[&=]/,$buf);
# ,
# & =.
$output = "Content-type: text/html\n\n
# MIME
<HTML><HEAD><TITLE>Result</TITLE></HEAD>
<BODY BGCOLOR=\"#FFAAAA\">
<H1>Hi there</H1><HR><BR>";
$i = 0;
while ($i <= $#ar) {
$ar[$i] =~ s/\+/ /g;
# +
$output .= "$ar[$i]\n";
# $output
#
$i++; }
$output .="<HR></BODY></HTML>";
# HTML
print $output;
}
eval &Print;
#
# ,
. CGI- ,
@ARGV
.
, URL:
http://www.host.ru/cgi-bin/name.cgi?123+resource+time+12
.
, CGI- Perl
.
CGI. www.perl.com
- Xbase.pm
.
: use
Xbase;
Xbase
:
$database = new Xbase;
$database
,
, .
:
$database->open_dbf($dbf_name,$idx_name);
DBF- . (database type) :
print $database->dbf_type;
, , Xbase
, DBF3, DBF4 FOX.
:
print $database->last_update;
.
:
$end=$database->lastrec;
.
:
$database->dbf_stat;
. display status
.
idx_stat
:
$database->idx_stat;
(STDOUT)
IDX-.
go_top
:
$database->go_top;
,
, ,
, .
go_bottom
:
$database->go_bottom;
,
, ,
, .
go_next
:
$database->go_next;
skip
1
, .
go_prev
:
$database->go_prev;
skip
-1
, .
:
$stat=$database->seek($keyvalue);
,
.
,
. , ,
.
,
:
$current_rec=$database->recno;
bof
true
,
.
if ($database->bof) {
print " At the very top of the file \n";
}
eof
:
if ($database->eof) {
print " At the very end of the file \n";
}
- :
print $database->get_field("NAME");
.
, _DELETED
.
:
@fields = $database->get_record;
,
.
close_dbf
.
$database->close_dbf;
, . , , .
#!/usr/bin/perl
use Xbase;
#
$database = new Xbase;
#
$d = "/home/smit/employee.dbf";
#
$i = "/home/smit/employee.cdx";
#
$database->open_dbf($d,$i);
#
$database->dbf_stat;
#
#
$database->idx_stat;
#
#
@fields = $database->get_record;
print @fields,"\n";
#
print $database->last_update, "\n";
#
$end = $database->lastrec;
print $end;
# 6.1 Perl 6.1.1 6.2 6.2.1 Oracle 6.2.1.1 6.2.1.2 6.2.1.3 6.2.1.4 6.3
Copyright (c) 2025 Stud-Baza.ru , , , .