        
     Perl    ,   -
        .     
,     ,  Perl      -
   -  .    -
      (file handle),  -
 ,   .   -
     Perl     ,
 Perl     :  STDJN,
STDOUT,  STDERR.       -
  STDIN, STDOUT, STDERR   . -
 ,    Perl    -
    .

         
          ,      
 open.    :

open(FileHandle[, FileName])

         open    -
 ,   open  Perl    mode  -
 . Perl   (mode)  ,  -
   .   12.3    -
    .

        
<FILE>                 (
                <r>   fopen)

<<FILE>             (  ,  <FILE>)
<>FILE>             ( <w>  fopen)
<>>FILE>               ( <+>
                 fopen)
<+>FILE>           / ( <rw> 
                fopen)
<+<FILE>           / ( <rw+> 
                fopen)
<| CMD>            ,  
                <CMD>
<CMD |>           ,   <CMD>

. 12.3.          
Perl

:   (pipe)     
  .

         open   ,  Perl -
,               
$FileHandle.     ,  -
 ,   close,   :

        close(FileHandle);

         open  
close:

   open(InFile, "test.dat") || die;     #   
                                        # test.dat

   open(OutFile, ">test.dat") || die;   #  test.dat

   $AuxFile = ">>test.dat";
   open(Aux, $AuxFile) || die;          #   
                                        # test.dat

   close(InFile);
   close(OutFile);
   close(Aux);

      ,       -
 .    ,    Perl
         
    ,     -
.   Perl   .
         MS-DOS  Perl    -
 ,    hinmode   -
 /       -
.           
   .          
MS-DOS       
   (CR+LF).      -
      ,   /-
   .      -
  binmode,     
.  binmode   :

binmode(FileHandle);

         
             -
   <FILEHANDLE'>.     Perl  -
 ,    ,   -
  (input-symbol). ,    
          
   Test.dat.

open(InFile, "Test.dat") || die;
while ($line = <InFile>)
        {
                print $line;            #    
        }
close(InFile);

          ,   -
 false,        -
 while.    ()  ,  -
 <>,    ,   -
.    ,        
<>,     .    @ARGV
 ,    <>   STDIN.  -
  @ARGV  ,  Perl    ,  -
   @ARGV,    .   Perl
   ,      .
      ,    <>  
 false.
       Perl      
      ,      
   . ,   -
    STDIN   @lines:

@lines = <STDIN>;

           .   
   ,     print.  
  print   :

        print [FileHandle]       List;

       print      -
 ,       STDOUT.      
    print    -
    :

        open(LogFile, '>>logfile.dat') || die;

        ##############

        ($m, $d, $y) = (localtime(time)) [4,3,5];

        print LogFile "Captain's log, Stardate ++m$/$d/$y\n";
        close(LogFile);

:         -
.

         
           -
   ,          
  .      ,  -
     ,    ,    
   sysread  syswrite    -
  .   sysread  syswrite   -
 :

$result = sysread(FileHandle, $Var, Length[, Offset]);
$result = syswrite(FileHandle, $Var, Length[, Offset]);

                  
(Offset),     ,     
 /.   sysread  syswrite    
,       .    -
     ,    -
    ,        
 .           
 (Offset),       ,  -
    /.
          ,      
   /:

$result = seek(FileHandle, Position, Base);
$result = tell(FileHandle);
$result = eof(FileHandle);

      seek     ,   fseek  -  -
     .  Position -
    ,     
  Base  :

? 0      
? 1      
? 2      

      tell  Perl     ,  -
 ftell     .   -
    ,      
  .  ,   eof,       
feof  ,    <>  <>,  -
          
.

       
      Perl       ,
     .    -
   ,   , 
     /,      
sysread  syswrite.    ,    -
<>  ,         
 <>  .

       
         Perl    ,  -
  sysread,         -
  . Perl    ,    
,           ,      
ASCII-.     Perl  -
  .      ,  Perl     ,
 -.      
 ASCII,     ,    .
      ,     
    ,   Perl    
.

            PERL
             ,   
  ,      .  
Perl  ,     unpack,    
  :

$result = unpack(Template, Expression);

     Expression    ,    
  ,   sysread,   
  ,       
.  Template       -,
,      Expression.
       
unpack:

($r, $g, $b) = unpack("C3", $color);#   3 

@longwords = unpack("L*", $data);   #     
#  
@stuff = unpack("S2L", $bin);       #   2 shorts  long

          , -
,      .       
  (*),         -
   .    ,   -
 .         
   Template.    12.4  ,
    Template      -
       unpack.

   
a                ASCII   
                ASCII   
b                 (   )
                 (   )
                  
                  
d                  ,  
f                  ,  
                
h                  ( 
                 )
                  ( 
                 )
i                 
I                 
l                   long
L                ,   
n                
N                
p                 
s                  
S                  
u                
v                
V                
                  
                  
@                    
     . 12.4.  

         
             -
     .     
 pack,    :

$result = pack(Template, List);

          -
 pack:

$color = pack("C3", $r, $g, $b);
$data = pack("L*", @longword);
$bin = pack("S2L", @stuff);

      pack      ,    
 unpack,    . , , , X, @.

       
     Perl        -
 ,        -
 .        
        .

     ,    
        Perl      -
 .          
    .      
  opendir,      
.    ,    ,  
  readdir.  ,      -
  closedir.     -
   readdir  ,    
     :

opendir(Dir, $INC[2]) || die;

while ($file = readdir(Dir))
        {
                print "$file \n"
        }

closedir(Dir);

          $INC[2J   -
   .  $INC[2]  $ARGV[0],  -
    ,    ,   
   .        
,     ,  Perl   
 ,        -
   :

$result = rewinddir(DirHandle);
$result = telldir(DirHandle);
$result = seekdir(DirHandle, Position);

      
             -
       print. -
  ,  Perl    printf  sprintf.
  Perl         
,   .

       PRINT
            print. -
 , Perl   ,  
   print.    12.5    
  .

   
$,              
$"                
$\              
$#              (  '%.20g
             ')

. 12.5.   ,     


              
   ,   . ,  -
      $    ,
     :

$, = '*';
@list = 1..10;
print @list;            #  1*2*3*4*5*6*7*8*9*10

     ,    $     
 ,     ,    . -
        ,   
,   print.

         PRINTF
     Perl   printf  sprintf,    
         .
   :

$result = printf([FileHandle] Format, List);
$result = sprintf(Format, List);

        printf     
   STDIO,   sprintf  -
 .          
  ,      
 Perl   (*).    
   printf  sprintf.

$precision = 2;
$pi = 3.1415;
printf("%.2f\n", $pi);                  #  3.14
printf("%.${precision}f", $pi); #  3.14

            PERL
           shell, Perl -
   ,   -
 .      -
      Perl. , , 
,       ,   
       .   -
        -
   Perl.   ,     -
   ,          
  system, exec  fork.

      
               -
   .       -
 .      ,  
 Perl        
.      ,    -
.      ,      
   ,    
   .

       
         ,  -
        , -
  .     Perl  
   ,        ,
   .      -
 ,   , ,   
  .            -
           -
 .

       
           ,    Perl  -
  .   12.6   -
  ,     Perl   -
 .

          
.                  ( 
                  )
(..)              
+                   
                  
?                    
*                    
[...]               
[^...]             , 

(...|...|...)      
^                 
$                   
{n, m}             n  m 
{n}                n 
{n,}               n 
\n\t etc.          , 
                  . .
\b                 
\                 
\d               
\D                
\s               
\S                
\w                 
\W               ,    ,
                 

. 12.6. ,    

     Perl    (, )  -
, . .   , ,   /pattern/.  -
       -
 Perl:

# the following regular expressions are true if:
/ig/                    # string contains 'ig'
/(b|d|f)ig/             # string contains 'big', 'dig' or 'fig'
/[0-9]+/                # string contains a number
/[A-Za-z][A-Za-a0-9_]*/ # string contains an identifier

          ,   -
.          -
 .    ,   Perl  -
     -,   -
 .

              

       Perl     ,
   .    , -
    ,      -
   :

        if ($str =~ /pattern/)

            <-
>,       ($str).     -
 ,     <>.  -
,   ,      Web
Programming:

if ($str =~ /Web Programming/)

      ,    ,   -
       .  ,  -
       <>,      
   $str          :
<banana>, <bananana>) <banananana>:

        ($str =~ /^ba(na) {2,4}$/)

      ,         
 ,   $str   <the>   -
   ,   <their>.

($str =~ /\bthe\b/)

           
          Perl    -
,     ,   , -
      .  ,    -
,              .
   ()      ,
        
   . ,   -
     ,    -
,     :

$str = " January 1, 1997, ";
($m, $d, $y) = $str =~ /\s*(\S*)\s + (\d+)\D + (\d{4})/;

              -
 :

?     ;
?    ,   ,   $m
(   );
?   ;
?      $d (   );
?   ,   ;
?      $ (   ).

     Perl         ,
  (=~),    -
:  (!~).                !($str
=~/pattern/).

           
          ,     -
 . , Perl    -
 ,      -
.        Perl    
,   ,   :

        $str =~ s/pattern/replacement/;

     ,        <colour>  
<color>:

$str =~ s/\bcolour\b/color/;

            <colour>
 <color>:

$str =~ s/\bcolour\b/color/g;

        g      Perl  
  .

       i,        -
 .         -
 ,      :

$str =~ tr/SearchList/ReplacementList/;

     ,        -
       :

$str =~ tr/a-z/A-Z/;    #  ,    

        :

$letters = "abcde";
print "$letters\n"                      #  abcde
$letters =~ tr/a-z/A-Z/;
print "$letters\n"                      #  ABCDE

     
             -
 Perl.     ,    
  CGI   Perl.     -
      CGI-     Perl,
     .   -
 ,  ,      
:

? Perl     ,
         
Web  Internet.

?    Perl      -
   ,  Perl   -
 ,       ,
     .

?  Perl       CGI-  
Web  Internet,       ,  -
     .

      WEB-    PERL
       Web     -
     Pcrl,   ,   -
      Perl 5   -
.    Web-      
.

http://www.shareware.com/top/Source-Code-table.html - SHAREWARE.COM
       -      .

http://www.inxpress.net:80/~moewes/computer/perl95.html - Perl 
       Windows 95.

http://www.mit.edu:8001/perl/perlapi.html - PERLAPI

http://www.genome.wi.mit.edu:80/ftp/pub/software/WWW/cgi_docs.html  -
       CGI.pm -  Perl5.CGI

http://www.metronet.com/0/perlinfo/perl5/manual/perl.html - PERL

http://www.teleport.com/~rootbeer/perl.html -   
       Perl