:


---------------------------------------------------------------
     © Copyright  
     Email: web@hackzone.ru
     WWW: http://www.hackzone.ru
     Date: 09 Sep 2001
---------------------------------------------------------------





       (internet)  --         ,  ,
     ,         
  TCP/IP.       --  
              .   ,       
-,                ,
  .      TCP/IP  
           
 "".      . 
--     ,       ,  
.                
        ,   
           .       
       ,     
 .



               , 
  ,    .    
  -      ,
  .          tcp/ip    ip- ,
      32-  ,       
216.122.167.55 (    0  255,  ). 
 ip-  32-   ,    
    -        ,      
,            . 
     255.255.255.0,       ip- 
    216.122.167   55.     
        .  ,       
  ,       
  -            
    .
             ,      
   Internet,          
  .      ,      ,  
  ,    -   
,   .


     . 1.    Internet

                    
"  Internet",           
      .          Internet
   ,     ,      
.           -  (proxy,  ).
          -     
,            ,    
 tcp/ip,      NAT, Network Address Translator, 
        :      
-             .
        ,        
.
              
. -,   ""  ip-,   
     ( , 32 ,   
 ip- --        ,    
          ip-, ipv6).  -,  
            ,  
    .  ,       
            ,     
            
 .



     Ip-    ,  
 . ,      216.122.167.55     .
            ip 
    .           
,                     ,
, -,  , -,   
    .
               
      (Domain  Name Servers,  DNS).    
   ,       
 .            ,
      .
                 (root)  ,  
 .        ,
        
    ..
             .com  ( 
 ), .edu ( ),  .net (
,   ), .org (,     
    ),          
     InterNIC,  .gov  (      
 ,        
        ,    US
Federal   Government  civilian  agency),   .mil  (     ,
  US  military agency),  .int  (  ). 
          
.  ,        
    (,  .ru, .de),   
  .



     Ip-          ,      
.     ,            
  Internet -     , ,
   ..       
    .    -   FTP
(File   Transfer  Protocol),    web-   -     
  HTTP(HyperText  Transfer  Protocol),    
  -  SMTP, POP3, IMAP  ..
          ,    
0  65534.       
. ,  FTP  21,  HTTP - 80, SMTP - 25, POP3 - 110.  ,
    ,       
       .        - ,
,             WWW. 
,            
  ,        
:  Windows-1251,  KOI8, Mac, DOS.        
     ,   
   --       .  
      .  -,      
          ,
    Win1251.  -,      
 -    .      . 
             ,   
     --     ,
     : ,  8080 -- Win1251,
8083 -- Koi8  ..



           (Uniform  Resource Locator,  URL)
      - ,   ..  
   URL   :
     []://[][:]@[][:][//][][?
]
          ,    URL
  . 
      -    ,   
  (, ftp, http);
      -  ;
      -            
,    ;
      -  ,     ;
      -  ,   ,    
  ;
       -          ,  
 ;
      -  ;
         -          
.



                   
  ,         (
,  ,    ..).    
     ,          
    ,   World  Wide  Web (WWW),   
  HTTP  (Hyper  Text  Transfer   Protocol  --      
 ).  ,    WWW,
        
--  ,    ,      ,   
,         .      
      HTML  (Hyper Text  Markup  Language --  
  ),     
      ,   
 ,          
.  HTML-      
-- .        
Navigator    Netscape (NN)   Internet Explorer    Microsoft
(MSIE).   NN      
  ,  MSIE      Windows ,
Macintosh    Unix-.
     HTML-      ,      
,  ,        
.  html-   :
     <html>
     <head>
     <title></title>
     </head>
     <body>
     <p> 
     </body>
     </html>

           :


     . 2.  html-
            ,            ,
   .    , , , <p>,
  ,     <body>   </body>,             
                
.      -- ,   
      ,          ..:  <body  bgcolor="white"
text="black">.
                  <html>,     
    --   .     
<head>,          (   
<title>)      ,        
.         <body>     
,   .     
            ,   ,
            ,  
 ,  ,   .    
   :
     <p>  --      ,      ,  
: <p align=right>;
     <br> --      ;
     --    ;
     --   ;
     <u></u> --   

                         <a
href="URL">...</a>,  URL --     . 
  ,       <a>,       
,               ,
      href.   
     <img src="URL">.



              
    WWW,      
   .        
  --      
 ,                
  HTML,      ,  ,  
    HTML.

     . 3.   , 
       
         (1),   (2) 
 (2)   -     .  
          (4),    
                  (5,6)  
    ..
            HTML       -
  ,        
 ,   .
                  
  WWW:
       .     WWW    ,
           ,  
         ,    
,   .      
 ,        
.         
      .
      .        --  
    -         
         ,            
 ,     ..
                 
      Web  --    
 ,  ,     ..
           ,    
 ,      .
                  
    :
        (plug-ins) Netscape;
       ActiveX;
      Java-;
        JavaScript, VBScript.;
     Macromedia Flash.
        .
             
      Netscape Navigator,    
.         ,    
       .
          ActiveX   
 OLE/COM-,          
   ,    Win32-.  
--        Win32-     
 Internet Explorer,   Netscape Navigator  plug-in,
        ActiveX.       ActiveX
           ,
           Internet   Explorer,     
       . 
             -- 
       ,  
   (, VeriSign Inc.),        
,     .     .
 ,     .
                  
      --     
    .
         Java-       
 .      , 
        ,  Java-       
 -,     Java-.
   -   ,       
  --  ,            
Java-.         
 Java-,         
-.     ,    Java-
--         -             ,
 Java-    
  .         ,  
        (JIT   --  just   in   time  compilers),
       ""  
 .    ,    
 (  , ++)     
--    native  code.         
     .
        Java-     --  
   (     ,  
     --   , 
  ..,      -,    
 " "  ..),      (
                   ,  
     ..,     
  ),          ,
  ,       .  ,
      .
       --       
   Java-.   Java-          
  ,            
     .   ,   
   --      Java      
   ,        
,    ,     
  .         
      ,         ,  
Java-,        ,    
     .       
      ,   
    .
       Java    .
    Java        
.               
  .          
           --   ,
        ,    ,    
,  ,   ..
           Java-      
  ,        
   .
     JavaScript,   VBScript    ..        
 ,      html- 
 .      , 
         ,    
..             ,    
    ,  ,  ""
html- (.. Dynamic HTML)  ..
     Macromedia Flash     ,   
  ,                 
web-,           Java.  
      ,   
--         (
  /  ,  ,  ,  ).  
 flash-      ,
     (  ,  
ActiveX-  Java-).




      ,   ,   
     .       
,      ..    
    .
                
       ,   
 ,    .
                , 
    .    ,    
   --         WWW.  
     
 HTML-.

          HTML                
  --  ,    ,    ,  .  
     <form>,   action  
   ,        .    method
      -- GET  POST.
     HTML-,           
 ,   :
     <p align="center">
     <form action="/cgi-bin/process.cgi" method="POST">
      1<br>
     <select name="answer" size="3">
     <option value="answer1" selected> 1</option>
     <option value="answer2"> 2</option>
     <option value="answer3"> 3</option>
     </select><br><br>
     <input type="submit" value="">
     </form>

            :

     . 4.        

         ,    -- <input>.    
       type                                :
submit/text/password/checkbox/radio/hidden,  , 
  ,    ,   , 
.
         name    ,   value
    .
             <select></select>,
      ,      <option>, 
  .
               Submit,  
    http-,    , 
     ,    action.
       ,      
,  CGI (Common Gateway Interface,   ).
    ,  CGI, Web-  
 (CGI-)     ,    
(,    Web-).    CGI-  
 ,      .
          .      
    ,   .1.



     . 1.   , www-  cgi-

        ,   html-  
  <form>,       "Submit".        
      CGI-  --     
  Location ,   <img>      
(SSI)  . .
                     HTTP-  
          .                    
param1=value1&param2=value2...&paramN=valueN,         parami    --    
    ,  valuei  --       . 
,              ,   ,   
,          %XX,
 XX  --     .   
      "+".   ,       
    GET,           URL
(,
<u>http://www.somehost.com/cgi-bin/script.cgi?param1=value1&param2=value2</u>).
    POST       
            (           ,            ,
application/x-www-form-urlencoded),    .    
         (   
).               
  :   ,   ,     
 ,  . .       HTTP-,
  ": ".          
  ,        .
       CGI-,            
           QUERY_STRING  (
 GET)      (   POST).  
   ,    HTTP_USER_AGENT,  REMOTE_HOST  .
  'njuj    HTTP-.
     CGI-                  
     (stdin)          QUERY_STRING.
 , ,    ,    
         http- Location,  
    ,        
(stdout).         HTTP-,    
 ,  ,   cookies  . . 
  .
           CGI-  ,      
          .    
        --      
     http- Location,      
.    ,    Content-type,
               --
, text/html   html-.
     ,          HTTP,      
CGI-      .
      CGI-    ,  
           . ,
  CGI-         
DOS,  Delphi, /++, Tcl, Visual Basic, AppleScript, FoxPro, Perl  . .
         CGI --   
 , -,           
,  -,              
.        HTTP-,  
        ,   
         . 
      ,       
      .
      ,   Unix-,     
      mod_perl  --   ,     
web- Apache     Perl.     
      CGI-,     Perl.   
     --  mod_perl    
Perl          Apache,         
      .      
  PHP  --    ,        
html-.    ,       html-  ,  
           PHP <?
 ?>. ,    ,       PHP,
   ,     
.          C,          
  .
          Windows-      Unix-.   
Microsoft Internet Information Server (IIS)   
ISAPI    Active  Server  Pages (ASP).  ISAPI-   
  ,      .  
           ,      
          .    
,   ISAPI-    
   web- (,    IIS4   
   ).
       ASP  PHP --    , ,  
   ASP  (<%   %>),     ,
,  ,   ISAPI-.  ,  
  ,             
  --         JavaScript     VBScript,      
 HTML.         HTML
--            
    .       ASP, , 
         ActiveX-.
         
.NET,            , Active
Server Pages+,           -  
.
                  
   web-,     CGI
--             Java Servlets,  FastCGI,
ColdFusion    ..            
--  --      
          .      
      ,          
    -        <form>    
,    .



               CGI- 
Perl.            ,    
          ,    ,
     .  .      , 
      Unix-,            
    ,          
.        Perl,     
  CGI.     ,  ,
   ,   Comprehensive Perl
Archive   Network  (CPAN,   <u>http://www.perl.com/CPAN/)</u>,     
       , 
,    ..



     Perl-            ,        
Perl-,               #!/usr/bin/perl   ,
     Perl.      Unix-,
,  ,        ,
  windows-      ,    
    (Apache/Win32,    ,    
CGI-     ).
                C,     
.              ,
           
   ,       ""  
,       .     
           
,              use  strict,   
        .   
      ,       , 
   --   ,    :
     print "Hello, World\n";
     print ("Hello, World\n");
         #,       
.   .
        Perl     --   .
          --  
          (,       ,   
  Perl,       double).       
  ,                  
   -         ,    
    .          
    --       
   :
     print "2"*2; #  4
            $:
     $a = 1;
                  ,   
        undef.     
undef       "",     
        defined.      
     0   ""  "0".
             .
        :
     print '12\n$a'; #   12\n$a
                       
   :
     print "12\n$a"; #  12,   ,  
 $a
                  
    ,           
  : "\$a".
                
(      **,  not, and, or, 
 !, &&, ||,    ,   ,
   xor,        ).    
    "." (),  
"x",  ne ( ),  eq (), lt ( "
")  gt (  "  ").      
  cmp,  --1, 0  1,    
,       <=>.
        chop      ,  
   chomp      ,          
     (    --   
\n,            
 $\).
             index($,  $,
$),        , 
 $ (    )   rindex,   
 ,      .   
   substr ($, $, $).    
          .    
      ,       
   .
       Perl       
  .       @: @a,   
      $a[10] (  
   0,         --1,
  --2    ..).          
        -- ,  chomp 
           , 
@a       .
           ,      , 
  undef,       
  ,          
undef.
          ,     
        ,  
   :
     @a = (0, $a, 5, "123", @b);
            @b   
  ,     , ..   
  @a.
                  
:
     ($a, $b, $c, @e) = ($b, $a, @g);
     $a   $b   ,  $c      
  @g,       @e.
               :
     @a[0, 1, 10];
           :
     ($a, $b, $c, $d)[0, 1];
         ,    ,        
:  localtime  ,   time
(      1.01.1970),    ,   
 "Fri Sep 15 11:12:13 2000",       (,
,  ,  , ,  ,  ,   ,   
):
     ($day, $month, $year) = (localtime(time))[3, 4, 5];
      ,  ,         ,
      ,      1900
.   ,  2000    100 (- , 
    ,   2000    
      1.01.100  1.01.19100).
          ","   => :
      ("one",  1,  "two",  2, "three", 3)  (one => 1,  two
=>2, three => 3),      .
                       push,
   (   )    ,   pop,
    .          
  unshift  shift.       
  @_.
      reverse     - 
      .    sort      
  ,     .
        ,   Perl   , 
.            ,      
      ,            .
  ,      (   ),
 ,  -- ,     %:
     %a = (one => 1, two =>2, three => 3);
            $a{1} (    
"one").
       key          ,  
values  --  .  each      ,
    -          .  
    delete:
     delete $a{1};
              ,      
    , .        Perl.   
         ,       
 :
     $ref1 = \$var;
     $ref2 = \@array;
     $ref3 = \%hash;
          ,    , 
  :
     $$ref1;
     ${$ref1};

     $ref2->[12];
     ${$ref2}[12];
     $$ref2[12];

     $ref3->{$key};
     ${$ref3}{$key};
     $$ref3{$key};

      ,          ->,
   .
             :
     $aref = [1, 2, 3];
     $href = {1 => One, 2 => Two, 3 => Three};

                
(,    ).



                
    ,        .    
       ,    
.                 
:
     if($a>$max) {$max = $a}
        if:
     if( 1)
     {...}
     elsif( 2)
     {...}
     elsif( 3)
     {...}
     ...
     else
     {...}

        if(!)    unless(), 
            if(){}   
  if .
            &&  ||:
        if(){}          &&
,      unless  (){}  --    ||
.                   
.

               ,      :  
while(!){}   until(){},      
-.       
while .
       for,      ,  
foreach,   
     foreach $i(@)
     {}

                $i    
     .  ,           ,
  ,  :
     foreach $i(sort keys %a)
     {
     print $a{$i}."\n";
     }

               each --
  :
     while(($key, $value) = each(%a))
     {
     }

           ,     -,  
 last,   ,  next,   
,    redo,             
 .       :
     OUTER: while( 1)
     {
     INNER: while( 2)
     {
     if( 3)
     {
     next OUTER; #     
     }
     }
     }


        :
     sub f
     {
     }

        f();
           return,   
     ,  
 .             
 @_,             
 : $_[0]    ..,       shift,  pop  ..
 ,      .
     ,     ,       
 :
     sub f
     {
     $a++;
     }
     $a = 1;
     f();
     print $a; #  2

       ,      ,        
  my:

     sub f
     {
     my $a;
     $a++;
     }
     $a = 1;
     f();
     print $a; #  1

              ,
  :
     my($param1, $param2) = @_;

           use  strict       
 my  .
       my        local. 
   : my       
, local         , 
   .
     ,        ,        
   .
     sub by_num
     {
     return $a <=> $b;
     }
     foreach $i(sort by_num keys %a)
     {
     print $a{$i}."\n";
     }

       by_num   ,    $a   $b,
  ,         .
      ,   :


     foreach $i(sort {$a <=> $b} keys %a)
     {
     print $a{$i}."\n";
     }

         :
     sub func{...}
     $fref1 = \&func;
     $fref2 = sub {...}; #    

         $fref1->( ).

     -
            <STDIN>:
     $a = <STDIN>; #     
     # 
     # (,  ,   $/)
     #  undef,    

     @a = <STDIN>; #       ( --
     #  Ctrl-Z);    
     #   
     while(<STDIN>) {...} #   
     #  $_.

                           print,
     --        printf,      
   .      print      , 
   $_.
           ,           ,
  <>:
     while(<>){...}
            ,   <>
   .
          -           
.      STDIN, STDOUT, STDERR    
 ,       , 
,      DATA,     ,
      __END__    ,        
.
           open:
     open(FILE1, "filename"); #    
     open(FILE2 ">filename"); #    
     open(FILE3, ">>filename"); #    
           open    "",
        :
     open (FILE, "filename") || die "cannot open file: $!";
      die       ,    $!
     .
          :
     close (FILE);

             -   , 
         --  ,    
 .
             <>  :
     @a = <FILE>; # C      . 
     #     ,   
     #  

                   
  print.       
 :
     print FILE "some text\n";
               "-e":  if(-e
$filename){...}.       ,    
   (-r),      (-w),    
(-d)    (-f)  ..
                Perl    DBM-,
     DBM-.   Unix-
 DBM         
 .       DBM,  
 , ,      ..    
    DBM-    dbmopen,   DBM-
 dbmclose:
     dbmopen(%A, "basename", 0644)
     dbmclose(%A);
           dbmopen  ,    
  ,      .     
,      undef.
                       perldoc
AnyDBM_File.<u></u>



               Unix, 
        Unix-,   grep,
awk, sed,   (vi, emacs),      . .
           ,   , 
  .  ,      ,  
  ,  .    ,    
        .
             $_,
           
 =~  !~:
     //; #  ,   $_ 
     #  ""
     $s =~ //; #  ,   $s 
     #  ""
     $s !~ //; #  ,   $s   ""

       ,  ,   
     s/1/2/;
       , :
     //i; #  
     s/$s//g; #   

           ,  
    .           
.           --    (".").   
   ,     .  
            ,    
 :
     /[]/;
           ,        
.       (   
   \-),   "^",     , 
   --                 ,
    .        
  :
     \d [0-9] 
     \w [a-zA-Z0-9_]  
     \s [ \r\t\n\f]  
     \D [^0-9]  
     \W [^a-zA-Z0-9_]  
     \S [^ \r\t\n\f]  

                  
,   .       --  "*"  
 "+".          
      ,  --    .
  "?"        ,     
,  ,         
  ,  .
     /ab*/; # ,  , ab, abb, abbb  ..
     /ab+/; # ab, abb, abbb  ..
     /ab?/; # , ab
     /ab{2}/; # abb
     /ab{2,4}/; # abb, abbb, abbbb
     /ab{2,}/; # abb, abbb, abbbb  ..

                :
"",  ""    .  "" ,   
       ,   
:
     $s = 'abbbbb';
     $s =~ s/a.*b/c/; #     "".
             ""  "",  
    :
     $s = 'abbbbb';
     $s =~ s/a.*?b/c/; #   "cbbbb".
     ""  ,          
    -- ,  /a*/   
,  * --  0   .
     ,            
 ,    . ..     
  ,             --  ,     
       .
            ,    
,   ,   ,  
  $1, $2, $3  ..:
     $s = 'abbbbb';
     $s =~ s/a(.*)b/c/; #  $1    "bbbb"

          --    \1, \2 
..   :
     $s = 'abbbbb';
     $s =~ s/a(.*)b/\1c/; #    "bbbbc"

          :
     /1|2|3/
           :
     /(a|b)c/;
          ,  
     /(?:a|b)c/;

            : /^a.*b$/
 ,   a    b,    \b
,         .
         ,    
 ,    ,          
    .          
       ,      ,       
               \Q...\E,
           
     :
     /\Q$var\E/

       tr            
  :
     $s =~ tr/abcde/ABCDE/;
      /e       s 
Perl-:
     $s =~ s/(.)/sprintf("[%s]", $1)/eg;
     ( ,         
           
sprintf).
               
 -- , ,    DBM-,   
 ,      .       Perl 
 split.    --  , 
   ,    .    , 
     ,     ,
  split:

     $s = 'abc:def:ghi';
     @a = split(/:/, $s); #  @a     -- "abc",
"def", "ghi".
          ,       $_.  
   ,   /\s+/.
        -- join  --          ,
   -,     :
     $s = join(":", @a);

        ,  ,     Perl,
   ,       
    .

     , , ,   
            .  
      main,   package 
   .     ,       ,
  $ߏ::ߏ.
                 ,      
  .            , 
,         .
                   use 
require.  use       (
Perl        ,   
         ), 
require     .
         Perl            
       ++,         
     .
         Perl    :
     $record = {
     NAME => 'record1',
     FIELD1 => 'value1',
     FIELD2 => 'value2',
     FIELD3 => 'value3',
     };
     print $record->{FIELD1};
     $records{$record->{NAME}} = $record;
     $records{"record1"}->{FIELD1} = 1;

       Perl   ,   --  ( 
         ),       bless  
.
          -,  
  .    
     sub new
     {
     my $class = shift; #   
     my $self = {}; #     
     bless($self, $class); #    
     $self->{FIELD1} = "value1";#   
     $self->{FIELD2} = "value2";
     return $self;
     }

              Class,     
 
     use Class;
     $object1 = Class::new("Class");
     $object2 = Class->new();
     $object3 = new Class;
        .
            ,       Class,  
,     ,              
    :
     sub f
     {
     my $self = shift;
     $self->{FIELD1} = shift;
     }

     , Perl-     ,  ++
     .



              web-        Perl
  ,         --  
   .    Perl -- "  
 " (There's more than one way to do it, TMTOWTDI).  
     ,               
,            ,    
        ,  ,   ,     
 -.    --  -- 
,        ,      
 ,      .



            .   
   ,                       
param1=value1&param2=value2...&paramN=valueN,      
          QUERY_STRING,      
  ,         CONTENT_LENGTH
  .  ,   ,  
 REQUEST_METHOD.
          Perl   
  %ENV,                
      read.     
       (          
    ):

     if($ENV{"REQUEST_METHOD"} eq 'POST')
     {
     read(STDIN, $query, $ENV{'CONTENT_LENGTH'});
     }
     else
     {
     $query = $ENV{'QUERY_STRING'};
     }

            :
     @params = split(/&/, $query);
       @params        param1=value1.  
           ,      
  :

     foreach $p(@params)
     {
     ($name, $value) = split(/=/, $);
     $value =~ tr/+/ /;
     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
     $in{$name} = $value;
     }

              hex    
" ->",    pack  --  
   ,         "
->".
                  
  %in,       $in{'param1'}.
           ,   
,        .. ,   
    .          
,          .
  ,     HTTP-.
      ,       --    
  ,    .     ,
    --      Location:
     print "Location: <u>http://newurl/text.html\n\n"</u>;
           ,      
 ,  ,  html-:
     print "Content-type: text/html\n\n";
     print               '<html><head><title>Ok</title></head><body>Results:
<br>...</body></html>';

       HTTP-        --
 ,   , cookie,    ..

        ,               
CGI-  ,       ,  
          . 
 ,     ,       
         ( 
 Perl 5.004)  CGI.pm:

     use CGI;
     $Query = new CGI;
     $val1 = $Query->param('param1'); #   
     $cookie1 = $Query->cookie('cookie1'); #   cookie

     #   cookie:
     $newcookie = $Query->cookie(
     -name=>'new', # 
     -value=>'value', # 
     -expires=>"+1y", #    
     -domain=>'www.mydomain.ru' #    
     );

        HTTP-:

     print $Query->header(
     -type=>'text/html',
     -cookie=>$newcookie,
     -Pragma=>"no-cache"
     # ...
     );

       CGI.pm      html-,  
     ..      
    perldoc CGI.



       web-  Perl     
--       HTTP-,     ,
         .    ,     
 .

     1.          .    
      ,       
   .

     use Socket;

     #     
     $forminfo = 'param1=val1&param2=val2';

     #    :

     #    TCP
     $proto = getprotobyname('tcp');

     #   
     socket(Socket_Handle, PF_INET, SOCK_STREAM, $proto);

     #    
     $port = 80;
     $host = "www.somehost.com";
     $sin = sockaddr_in($port,inet_aton($host));

     #   
     connect(Socket_Handle,$sin) || die ("Cannot connect");

     #   ,   

     #   GET
     send Socket_Handle,"GET /cgi-bin/env.cgi?$forminfo HTTP/1.0\n",0;

     # HTTP-
     send Socket_Handle,"User-Agent: my agent\n",0;
     send Socket_Handle,"SomeHeader: my header\n",0;
     send Socket_Handle,"\n",0;

     #      
     # ,    .
     while (<Socket_Handle>)
     {
     print $_;
     }
     close (Socket_Handle);

              
      %XX,   XX  --    .
   :
     $value=~s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;

     2.          --     IO::Socket.
     POST:

     use IO::Socket;
     $forminfo = 'param1=val1&param2=val2';
     $host = "www.somehost.com";
     $socket = IO::Socket::INET->new(Proto => "tcp",
     PeerAddr => $host,
     PeerPort => "http(80)")
     or die ("Cannot connect");
     $socket->autoflush(1);
     $length = length($forminfo)+1;
     $submit = "POST $path HTTP/1.1\n".
     "Content-type: application/x-www-form-urlencoded\n".
     "Content-length: $length\n".
     "Host: $host\n\n"
     "$forminfo\n";
     print $socket $submit;
     while(<$socket>)
     {
     print;
     }
     close $remote;

     3.   ,                --
     libwww-perl,    LWP.  LWP,  ,
         Perl,   ,  
   CPAN   <u>http://www.linpro.no/lwp/.</u>
       ,           LWP  (   
          perldoc
< >):
     LWP::UserAgent
     LWP::Simple
     HTTP::Request
     HTTP::Response
     HTTP::Headers
     HTTP::Cookies

     LWP::Simple         
       GET:
     use LWP::Simple;
     $content = get('http://somehost/text.html');

     LWP::UserAgent  --          web. 
 --     ,      
  :

     # 
     $UserAgent = new LWP::UserAgent;
     #     ""
     $UserAgent->agent("MoZilla 9.0 (non-compatible; MSIE 9.3; PalmOS)");
     #   
     $UserAgent->proxy('http', $proxy);

     HTTP::Request       , HTTP::Headers
--    :
     #  
     $Headers = new HTTP::Headers(Referer => $referer);
     #  
     $Request = new HTTP::Request(POST => $url, $Headers);
     # ,     
     $Request->content_type('application/x-www-form-urlencoded');
     #  
     $Request ->content($forminfo);

          request, 
 HTTP::Response:

     $Response = $UserAgent->request($Request);
     if($Response->is_success) #   
     {
     #  ,  
     $text = $Response->content;
     }

           cookie       HTTP::Cookie    
cookie_jar,               
  Cookie:
     my $ookieJar = new HTTP::Cookies;
     $UserAgent->cookie_jar($CookieJar);

         cookie  
     $CookieJar->load($cookiefilename);
     $CookieJar->save($cookiefilename);
              set_cookie.

          ,     , 
HTTP- Authorization.       
(   BASIC)          "_:",      
basic-       base64.            
  MIME::Base64:
     use MIME::Base64;
     $authorization = MIME::Base64::encode_base64("$name:$password");
     $Request->header(Authorization => "BASIC $authorization");

        
            Perl     
  DBI,      
      .          
(,       )   
,      mySQL.
           DBI:
     use DBI;
         :
     my    $dbh   =    DBI->connect('DBI:mysql:hostname:base:port',   'user,
'password, { RaiseError => 1, AutoCommit => 1});
      $dbh --   ,    ,
DBI:mysql:hostname:base:port  --       ,     
,   ,  ,     ,    ,  
  sql-, user/password  --       ,
   ,      .
          :
     $dbh->disconnect();
           .  ,  
      ,   do,  
   SQL-:
     $dbh->do("insert into mytable values (1,1)");
            ,  
:
     1.       prepare:
     my $sth = $dbh->prepare ("select * from mytable where field1>1");
     2.  :
     $sth->execute();
     3.  .     :
     fetchrow_array
     fetchrow_hash
     fetchrow_arrayref
     fetchrow_hashref

        , ,    , 
 ,        .    
   ,         
 ,    false:
     while(my $hash_ref = $sth->fetchrow_hashref)
     {
     foreach my $fieldname(keys %$hash_ref)
     {
     print "$fieldname: $hash_ref->{$fieldname }\n";
     }
     print "\n";
     }

     4.  :
     $sth->finish();
              
     $dbh->quote(),      
        .
      ,      :
     $sth = $dbh->prepare("select * from mytable where field1=?");
     $sth->bind_param(1, " ");
     $sth->execute();
     
     $sth = $dbh->prepare("select * from mytable where field1=?");
     $sth->execute(" ");

               quote     ,    
.
              
     .        
        prepare,       
 execute  ,  .






      .
         Perl,    ,
 -.

      .
         Perl    ,    ,
,      ,          
 ( ,   ,    ..),  
    (, ,   ..).

       .
       use strict;
             
,   --  ;
          : , , 
,     ,   ,   ;
                   
;
        dbm-;
                
,       ( ) .




      .
        CGI-  Perl.

      .
                  CGI-,
   web-.

       .
            
CGI.pm;
                          ,
    ,     
   cp866->win1251.



      .
        Perl-   .

      .
       CGI-  ,           
dbm-,     mySQL.

       .
           ,    
dbm-,   mySQL;
        ;
       ,         (,
  ..).



      .
               ,   
 http.

      .
         Perl         ,
     dbm-       ,        
CGI-              http   
  .

       .
       LWP;
               
  %XX,   XX  --     , 
    cp866->win1251.





      .,   .     Perl DBI/.  . -- :
-, 2000. -- 400 .
      .,  . Perl.  /  .
-- .: "", 2000. -- 736 .
       .          /.    .   --  .:
  " "  "Channel  Trading Ltd.", 1999,  --
384 .
      .,   .   Web-/.    .  -- .:
  BHV, 1997. -- 368 .
      .,  .  Perl/.  . -- .:  
 BHV, 1998. -- 320 .


Last-modified: Sun, 09 Sep 2001 17:58:10 GMT
: