:


---------------------------------------------------------------
   © Copyright (C)   
          :
    maslov@klgtts.kaluga.su
    maslov@news.kaluga.rosmail.com
---------------------------------------------------------------

           Perl  5.003
  Unix FreeBSD 2.1.0.
===============================================================








                 
 Perl.
                 
     .        
    Perl    5.003      Unix
FreeBSD 2.1.0.

         ,            
 .

(C)   .



             
    ,     ,  
          
 Perl  5.003     FreeBSD  
2.01.             
 OS/2 , MS-DOS  Windows NT         
  ,    .



		#!/usr/local/bin/perl
		#   test1.pl
		print "   !\n";

     .

#!/usr/local/bin/perl
	       -.
       -   -.

#   test1.pl
	   .   
 '#'        
    "  
",          .
   .       
.

print "   !\n";
	     .   
   "   !".

  print -   "".     -  ,
\n -    ';' -   .  .
           
 ';'.      '#' -   
  .

   
         
    "hello", "hello all", "  ",
"  "  .  ..

      ,      10$,  
     !
     ,    "  ".
,  ,    .
    test1.pl .   
:

	chmod +x test1.pl

     .   :

	which perl

     : /usr/bin/perl

: perl: Command not found.

      .      
  .        
  man ( - man   manual      ).

     01      which.
   :

	test1.pl

   50$      ,   
:

	./test1.pl

  ,   .       
 test1.pl  ,       .



	#!/usr/local/bin/perl
	open(PASS, "</etc/passwd") || die "  !";
	while(<PASS>)
	    {
	    print;
	    }
	close(PASS);

:

open(PASS, "</etc/passwd") || die "  !";
	""  ..    PASS 
    "  !"   .

while(<PASS>)
	         $_.

  {
	  .

  print;
	      $_

   }
	 .

close(PASS);
	 .      -  
   .

         cat /etc/passwd.
         
   !
        
       ( ).



      #!/usr/local/bin/perl
      open(PASS, "</etc/passwd") || die "  !";
      while(<PASS>)
          {
	    ($login, $pass, $uid, $gid, $name, $home_dir, $shell) = split(':');
	    print "$login \t $name\n";
          }
      close(PASS);

:

($login, $pass, $uid, $gid, $name, $home_dir, $shell) = split(':');
	     ,    ':'.

print "$login \t $name\n";
	 login -     .    '\t' - .




	#!/usr/local/bin/perl
	open(PASS, "sort -n -t : +3 -4 +0 /etc/passwd|") || die "  !";
	while(<PASS>)
	    {
	    ($login, $pass, $uid, $gid, $name, $home_dir, $shell) = split(':');
	    print "$login \t $gid \t $name\n";
	    }
	close(PASS);

:

open(PASS, "sort -n -t : +3 -4 +0 /etc/passwd|") || die "  !";
	    !     
   sort     .


 .

           .


#!/usr/local/bin/perl

open(PASS, "sort -n -t : +3 -4 +0 /etc/passwd|") || die "  !";
while(<PASS>)
    {
    ($login, $pass, $uid, $gid, $name, $home_dir, $shell) = split(':');
    write();	#   .
    }
close(PASS);
exit 0;		#  

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

format STDOUT =

: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
				$name
              ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                $name
              ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                                $name
----------------------------------------------------------------------
Login:@<<<<<<<<   Uid:@<<<  Gid:@<<<  Home dir:@<<<<<<<<<<<<<<<<<<<<<
      $login,         $uid,     $gid,          $home_dir
----------------------------------------------------------------------

.	#    


 :

:  - .   
              .     
               . 2-23-06,,,
----------------------------------------------------------------------
Login:uucryst     Uid:1055  Gid:66    Home dir:/var/spool/uucppublic/
----------------------------------------------------------------------


:   ,,,


----------------------------------------------------------------------
Login:uudilen     Uid:1075  Gid:66    Home dir:/var/spool/uucppublic
----------------------------------------------------------------------

       ,  
       .
 !





	perl []  

     ()   :

	1.       '-e'

	2.      .  
	   #!/usr/bin/perl  ""
	 .

	3.  /      
	  .     
	       
	 '-'.

  1  2        
  '-x',      
   '#!'      'perl'.
    '__END__'.
   '#!'    .  '#!/bin/perl -d'
  .

 ""       
.      .
    .    
 exit()  die()      exit(0)
   .




 - .   \0.


    (split)  $_
  $F.    -n  -p.


       .


    .


   .  -d14 
    .

	1	p	 
	2	s	 
	4	l	  
	8	t	 
	16	o	  
	32	c	/ 
	64	p	    -P
	128	m	 
	256	f	 
	512	r	   
	1024	x	  
	2048	u	 
	4096	L	"" 
	8192	H	 
	16384	X	 scratchpad
	32768	D	



        .


        -a


       '<>'.
          ,  
 .

:
	perl -p -i.old -e "s///" file

	-    ""  ""   file
	     file.old


 includ-    .    -P
   /usr/include  /usr/lib/perl.


    .    .
1.        -n  -p
2.     $\.  
      print   .


      
  .     sed  awk.
 BEGIN  END      
.    .


    -n     .


    .  
      'if', 'else'  'define'
..    - .


       .
    '-'  ,    
      true.


   PATH   .
       
"#!"      .


  ""  .     
     (setuid, setguid).
  CGI .


     .  
       
  undump.


   .   
     .


   .


      ,  
   ,   ,
    ,    
   "",     ,
   ,   100 .


       
 .       '#!'
     perl.  -   '__END__'
      .
        
   DATA.




  ()      .
        
  ().    , , 
 0  null.



   .     '#' 
   .
          
 (statements)       
.          .
     
      .

:
	sub test;	#   test

	$var1 = test $0; #    .

       
 require      
   use.  .  .




  
  ';'      
   ';'  .    
  eval{}  do{}     
          
.

     single 
 ';'.   single :

	if EXPR
	unless EXPR
	while EXPR
	until EXPR

 EXPR -     true  false.
 while  until       do   .

if EXPR		-  "".    EXPR  true.

:
	$var = 1;
	$var2 = 3 if $var > 0; # : $var2 = 3

while EXPR	-  "".      EXPR = true

:
	$var = 1;
	print $var++ while $var < 5; #  $var  

: 1234


until EXPR	-  " ".        EXPR = false

:
	$var = 1;
	print $var++ until $var > 5; #  $var  

: 12345

unless EXPR	-  " " .   if.    EXPR = false.

:
	$var = 1;
	print $var++ unless $var > 5; #  $var  

: 1




    
  .     
 ,     eval{} 
       
 '{}'.

    :

	if (EXPR) BLOCK
	if (EXPR) BLOCK else BLOCK
	if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK

	LABEL while (EXPR) BLOCK
	LABEL while (EXPR) BLOCK continue BLOCK
	LABEL for (EXPR; EXPR; EXPR) BLOCK
	LABEL foreach VAR (LIST) BLOCK
	LABEL BLOCK continue BLOCK

 ,       
      C  Pascal.  
      .

if (EXPR) BLOCK		-    EXPR   true   .

:
	$var =1;
	if ($var == 1)
	   { print $var,"\n";
	   }
: 1


if (EXPR) BLOCK else BLOCK2	-   EXPR=true  BLOCK  BLOCK2.

:
	$var =2;
	if ($var == 1)
	   { print "\$var = 1\n";
	   }
	else
	   { print "\$var   1\n";
	   }

: $var   1

if (EXPR1) BLOCK1 elsif (EXPR2) BLOCK2 ... else BLOCK	-
	 EXPR1=true  BLOCK1   EXPR2=true 
	BLOCK2  ...  BLOCK.

:
	$var = 1;
	if ($var == 0)
	   { print "\$var = 0\n";
	   }
	elsif ($var == 1)
	   { print "\$var = 1\n";
	   }
	else
	   { print "  \$var\n";
	   }

: $var = 1

 while  BLOCK     EXPR = true.  LABEL 
       ':'.
       
 next, last  redo.      
      .
  continue      
  EXPR.   EXPR3   for
          
   next.



next	-  continue  .     
	..  .

:
	M1:
	while ($i < 6)
	    {
	    ++$i;	#    1
	    next M1 if $i < 3; #     $i < 3
	    ++$i;	#       1
	    }
	continue
	    {
	    print "$i "; #  $i
	    }

: 1 2 4 6

last	-   break   .   .
	 continue .

:
        M1:
        while ($i < 6)
            {
            ++$i;       #    1
            last M1 if $i > 3; #     $i > 3
            ++$i;       #       1
            }
continue {
            print "$i "; #  $i
}

: 2 4

redo	-      EXPR    continue .

:
        M1:
        while ($i < 6)
            {
            ++$i;       #    1
            redo M1 if $i == 3; #    $i = 3
            ++$i;       #       1
            }
continue {
            print "$i "; #  $i
}

: 2 5 7




	LABEL for (EXPR1; EXPR2; EXPR3) BLOCK
 for    for  .   
  EXPR1,  EXPR2 = true  , 
 EXPR3.

:
	for ($i = 2; $i < 5; ++$i)
           {
           print $i, " ";
           }
        print "\n  i = $i\n";

:
	2 3 4
	  i = 5



	LABEL foreach VAR (LIST) BLOCK

 VAR      LIST
  .  VAR    
  $_.       VAR
       .. VAR 
    .
  foreach    for -   .

:
        @ = ("","","");  #  
        foreach $i (@)
            {
            print $i," ";       #  $i
            }

:   

:
        @ = ("","","");  #  
        foreach $i (@)
            {
            $i = uc($i); #    
            }
        print @;

: 

:

	for $i (3,5,7)
	    {
	    print "$i ";
	    }
: 3 5 7




          
      . 
   next, last, redo -  
.     switch () .
     switch    
       .  
       
  if ... elsif ... else ...   
  :

	SWITCH:
	{
	if ($i ==1 ) { .....; last SWITCH; }
	if ($i ==2 ) { .....; last SWITCH; }
	if ($i ==3 ) { .....; last SWITCH; }
	$default = 13;
	}

    .




    goto   ,     
    "  ".
      ""   
 ""   .   
      
  ""    goto .

     goto. goto - , goto - 
 goto - .

goto -       .

goto -  -       .
	          
	"M1:", "M2:"  "M3:"     
	$i  0, 1  2      :

	goto ("M1", "M2", "M3")[$i];

	 $i      
	 .

goto  -    ..    
  "" .



        
   .     POD .
       
  '=' :

	= head   

     '=cut'.    
      . 
    pod   
   .



      : ,   
 (hashes) -   .   
  ,   - . 
       .  
 .

       '$'  
  .



	$var1		#   'var1'

	@var1[0]	#    'var1'

	$var1{'first'}	#     'first'


     ""   ""
     '@'.



	@var1		#    var1 ( $var1[0], $var1[1], ... $var1[n])

	@var1[1,3,10]	#  $var1[1], $var1[3], $var1[10]

	@var1{'first','last'} #     ( $var1{'first'}, $var1{'last'} )

 ""    '%'.

:

	%var, %key, %years

    '&'     
  .

:

	&sub1, &test_prog, test(12)

      '*'.

        $var1  $var1[0]
  ,  $var1[0]   @var1.  \
@var1  %var1 -   .

     -   
  .      .
      $var1  $Var1 - 
.          
 .



      
      ..  
    "" .
     :    (list).
            - 
  .    - .

:

	$var1 = <>;	#    

	@var1 = <>;	#       @var1

	$var1 = (1,2,3); # $var = 3 -  

	@var1 = (1,2,3); #   @var1   1,2,3



     ,     .
    ,   .
  -     .
      ,  
     .  -   
         
    .

     ""  ""  ""    .
        .

    "TRUE" ()    
     0.

      (null)  - 
(defined)    (undefined).   
  -  .   
,    .    defined()
     .

        
 $#   csh.  $#var1 - 
   .    
   0    
 $#var1+1 .   $#var1 -  
   "" .
        $#var1
-   ,      -
.

        ( 
  ).

:

	@var1 = (4, 3, 2, 1);	#    
	$i = @var1;		#   
	print $i;		#   4 - - 
	print @var1;		#  ,   .

      
 scalar().

:

	print scalar(@var1);	#       

     "true"  
    "-".   
 2/8  8 -   ""  
2 -  .

 .

  :

	123
	123.123
	0.12
	.12E-10
	0xABCD		#  
	0377		#  0   - 
	123_456_123	#      .

   (')   (") :

	', !'
	"  ."

    .   
 qq.
          .

:

	$var1{first}     $var1{'first'}

          
       -  
   .
      __LINE__
(   ), __FILE__ ( ).
       __END__
   ,     
  DATA.

        
          
      ""  
.

         .
  "here-doc" ( ) .  
<<    -.

:

	print <<EOF;	#    EOF -   .

	  ,   !

		 .
	EOF



 -       
  .      
 .

:

	@var1 = (1, 2, '', 1.2); #   .



		$var1[0] = 1,

		$var1[1] = 2,

		$var1[2] = ''

		$var1[3] = 1.2


	$var1 = (1, 2, '', 1.2);

  $var1 = 1.2 ..   .

     ,    
       .

:

	@s1 = (1, 2, 3); # 	 

	@s2 = (6, 7, 8);	# 

	@s = (0, @s1, 4, 5, @s2, 9, 10); #   @s1  @s2

	print @s;	# : 012345678910  -   .


     ()   -.
      ,   
     .

:

	print ('','','')[1];

: 

           
         .

:

	($a, $b, $c) = (1, 2, 3); # $a = 1, $b = 2, $c = 3

       
.

:

	$x = (($a, $b, $c) = (1,2));  #  $x=2

        : -.

:

	%_ = ('', 31, '', 30);

: $_{} = 31, $_{} = 30

       => .

:

	%_ = (
			 => 31,
			 => 30,
	);



      typeglog  
  .      '*'.
         , 
       
     .
        
  .      
         :

sub new_sub
{ local *IN; #   
open (IN, "test") || return undef;  #  .   .
.........
return;
}

      .



         .
     "" 
..          '$'
         
 - .      ""
        :

	use English;

           
     :

	use FileHandle;

     :

	  



	 -> ()


          () .
        
      .




	 -       .
          
  .


	      
     .   
   .     1.


$MATCH
	      .


	   .


$POSTMATCH
	    .


$LAST_PAREN_MATCH
	       "".


$MULTILINE_MATCHING
	      1 
       
..   '\n' -  .    0
   .    5    
  .


$INPUT_LINE_NUMBER
$NR
	     .
      .


$RS
$INPUT_RECORD_SEPARATOR
	 -    .    '\n'


$OUTPUT_AUTOFLUSH
	        
      .    -0


$OFS
$OUTPUT_FIELD_SEPARATOR
	    print   
  .


$ORS
$OUTPUT_RECORD_SEPARATOR
	  print    .


$LIST_SEPARATOR
	 "$,"      
  "....".


$SUBSEP
$SUBSCRIPT_SEPARATOR
	 -       
.   '\034'.


$OFMT
	     .


$FORMAT_PAGE_NUMBER
	      .


$FORMAT_LINES_PER_PAGE
	  .   60 .


$FORMAT_LINES_LEFT
	    .


$FORMAT_NAME
	   .    .


$FORMAT_TOP_NAME
	     .


$FORMAT_LINE_BREAK_CHARACTERS
	     .  
     '^'.   '\n-'.


$FORMAT_FORMFEED
	   (  ).   '\f'.


$ACCUMULATOR
	    write()  format().
       
 formline() .. write()     .


$CHILD_ERROR
	      
:  pipe,   system(), wait()  `...`.


$ERRNO
$OS_ERROR
	      errno.
  -    .  
        
        
 die().


$EVAL_ERROR
	     eval().


$PID
$PROCESS_ID
	  .


$UID
$REAL_USER_ID
	 UID  .


$EUID
$EFFECTIVE_USER_ID
	 UID  .


$GID
$REAL_GROUP_ID
	 GID  .


$EGID
$EFFECTIVE_GROUP_ID
	 GID  .


$PROGRAM_NAME
	  .     
        ps,   
   .


	      .
   - 0.


$PERL_VERSION
	   .    perl -v
       .
         / 1000.


$DEBUGGING
	    '-D'.


$SYSTEM_FD_MAX
	     (system file
descriptor).   2.


$INPLACE_EDIT
	  inplace-edit .
   undef.


$PERLDB
	  .      
   .


$BASETIME
	     1970    .


$WARNING
	  '-w'. true -   false - .


$EXECUTABLE_NAME
	  .  argv[0]  .


	     '&lt;>'.


	    .
! @#ARGV -     1 ..
$ARGV[0]    (  ).


	     
   do, require  use.


	       
  do  require.  -  ,   - .


	 %ENV    . 
       .


	 %SIG     
   INT, QUIT, PIPE, ...
 'DEFAULT' -   .
'IGNORE' -   .



      .  
           s//
m/   =~  !=  ..
         :

	i	-      .
	m	-   .
	s	-  .
	x	-   (    )

      '/x'.    
 ,    (?...)

    (pattern)      regexp
  .      
  V8   (Henry Spencer)  
   .

     ( 
  )   egrep - :

	\	-      .
	^	-  
	.	-   .  '\n' -  .
	$	-  
	|	-  ()
	()	- 
	[]	-  

   (  ):

	*	-  0    
	+	-  1    
	?	- 1  0 
	{n}	-  n 
	{n,}	-    
	{n,m}	-   n,     m

        ()
.   '*'  {0,} , '+' - {1,}
 '?' - {0,1}. n  m     65536.

    "" (greedy). 
       
  .    "  "
   '?'.     
  .  :

	*?	-  0  
	+?	- 1  
	??	- 0  1 
	{n}?	-  n 
	{n,}?	-   n 
	{n,m}?	-    n   m 

           
 `\` -  (-):

	\t	-  
	\n	-  
	\r	-  
	\A	-  
	\v	-  
	\a	- 
	\e	- escape
	\033	-   
	\x1A	- 
	\c[	- control 
	\l	-    
	\u	-   -//-
	\L	-       \E
	\U	-   -//-
	\E	-   
	\Q	-    

     :

	\w	- -  '_' 
	\W	-  -  '_' 
	\s	-  
	\S	-   
	\d	-  
	\D	-   

     "" .   
 . :

	\w+	- 
	\d+	-  
	[+-]?\d+	-   
	[+-]?\d+\.?\d*	-   

    .   
    .  :

	\b	-  
	\B	-   
	\A	-  
	\Z	-  
	\G	-   m//g

  (\b) -      \w  \W.
   '\b'   backspace ().
 \A  \Z -  '^'  '$'    '^'
   '$'       
 \A  \Z       .

     ( )
      '\'.
           
 '$'.     :

	$+	-   
	$&	-  
	$`	-   
	$'	-   

:

$s = " 1  2   3";
if ($s =~ /(\d+)\D+(\d+)/)
    {
        print "$1\n";	#  '1'
        print "$2\n";	# '2'
        print "$+\n";	# '2'
        print "$&\n";	# '1  2'
        print "$`\n";	# ' '
        print "$'\n";	# '   3'
   }




(?#)	-    .

	(?:)	-    '( )'    

	(?=)	- "" .  /\w+(?=\t)/
			     
  '\t'    .

:
$s = "1+2-3*4";
if ($s =~ /(\d)(?=-)/)  #      '-'
    {
        print "$1\n";   #  '2'
   }
else { print " \n";}


	(?!)	- ""   .

:
$s = "1+2-3*4";
if ($s =~ /(\d)(?!\+)/) #       '+'
    {
        print "$1\n";   #  '2'
   }
else { print " \n";}


	(?ismx)	- "" .    
	      .




	1.         .
	       
	  '\'.
	2.      .

	3.    ()   
	 '[]'         
	    .     
	 '^' -        
	    .    
	 '-'   .  a-z
	     , 0-9 -   ..

	4.  ,     
	 '\'    .

	5.     '|'
	       .

	6.      ""
	          '\'
	    '\1'.



                   
   C.        
 ,     .

	.	    
	-----	---------------------------
		    
		->
	 -	++ --
		**
		! ~ \  +  -
		=~ !~
		* / % x
		+ - .
		<< >>
	  -	  
	  -	< > <= >= lt gt le ge
	  -	== != <=> eq ne cmp
		&
		| ^
		&&
		||
	  -	..
		?:
		= += -= *=  ..
		, =>
	  -	  
		not
		and
		or xor




     .   
,    ,    
 ,      .  
          
        .  
 "".
     ( print(),  ..)  
 (chdir(),  ..)    ,  
    .      .

        
         .

:

        @i = ('a ','b ', print 'c ', 'd ');
        print "\n",@i,"\n";

:
	c d
	a b 1

     print.      
  ,     .
       print  
'c d'          @i
  print  .



      ++    . 
    [...]  {...} ,    
        .
          
 ,       .  
 "".



        .    
      1   
.        
.

         .
      (, , )  
  .      
   .

:
	print ++($i = "09");	#  "10"

	print ++($i = "a9");	# "b0"

	print ++($i = "az");	# "ba"

	print ++($i = "aZ");	# "bA"



:
	print 4**2	#  16

	print -4**2	#  -16 .. -(4**2)



	'!'	-  

	'-'	-  

	'~'	-   (  1)

	'+'	-  

	'\'	-     ( &  )



       ""           
   .        ""  .
  =~        (pattern -
, , )  .            
     $_     
       .      
  .          ,
      .     
  ..        
      .     !~    =~  
    ( "").  
     "".



	'*'	-  

	'/'	-  

	'%'	-  

	'x'	-  
        
   .   ,     
   -  .

:
	print '*' x 5;	#  '*****'

	print (1,2) x 3; #  121212




	'+'	-  

	'-'	-  

	'.'	-  () 



	'<<'	-        
		     .

	'>>'	-        
		     .



     .    .



	'<'	-  

	'>'	-  

	'<='	-    

	'>='	-    

	'lt'	-  

	'gt'	-  

	'le'	-    

	'ge'	-    



	'=='	 true      ()

	'!='	-  

	'<=>'	- -1     , 0  ,
		1  .

	'eq'	-  

	'ne'	-   

	'cmp'	-   '<=>'   



	'&'	-  AND

	'|'	-  OR

	'^'	-  XOR



	'&&'	-     false,   .

	'||'	-     true,   .

        ,    
  0  1.       .



           . 
      .  
            - .
           1.
             ..  
    .    
     .
 :
	for $i (1..4)
	   { print "$i ";
	   }
: 1 2 3 4

    -  .  '..'
    .  false
      false.    
 true  - true     true,  
  - false.       
   '...'.
      false   
      true. 
 '..'    '&&'  '||'. 
  flase -  ,  true -  
  1.       .
     "E0"   
      .

:
	@ = ('a'..'z'); #     

	@ = (0..9);	#  

  '?:'

        .    '?'
     ':' -   ':'.

:
	$i = 1;
	$i > 1 ? print "" : print "";

: 



	'='	-   ""    
       ..

	$i += 2;

	$i = $i + 2;
     .
  :

	**=
	+=	-=	.=
	*=	/=	%=	x=
	&=	|=	^=
	<<=	>>=
	&&=	||=

       '='.




     ,  
        .
       
    .



 not     
.   '!'     .



    .  '&&'
      "" . .
    false -   .



    .  '||'
      "" . .
    true -   .

 xor ( ).
   .   
   .


        :
	 &	-  .    '\'.

	 *	- .

	(TYPE)		-  .




     ,     
       .  
     .   
   .   '{}' 
    .   
 ( '()',  '[]',  '{}',  '<>')
        .

   		     
   ----------	------	------------	----
	''	q{}	Literal		
	""	qq{}			
	``	qx{}			
		qw{}	 	
	//	m{}			
		s{}{}		
		tr{}{}		

       
 '$'  '@' -  ..   
   .
     :

	\t	 
	\n	  
	\r	
	\f	 
	\v	 
	\b	backspace ()
	\a	
	\e	escape
	\034	 
	\x1a	 
	\c[	 
	\l	   
	\u	   
	\L	      \E
	\U	      \E
	\E	  
	\Q	    \E

    .  
     
    .   
 '\Q'.      
    .


    //  
  .      
      .   
       
  .


/PATERN/gimosx
     ().    
  true (1)  false ('').    
   '=~'  '!~'     $_

:
	g	-  .   .
	i	-      (  )
	m	-  .
	o	-  
	s	-  
	x	-    .

 '/' -    'm'  .  
         .

PATTERN      
()     .
 $)  $|  .     
     -  /o.
        
          .

 PATERN -      
.

      
      ($1, $2, $3...).
     $1.

:
	$a = "/usr/local/perl/perl.bin"; #  

:	  @dirs   .

:
	    split('\/')
	     .

	@dirs =~ m[/(\w*)/(\w*)/(\w*)/(\w*)]

 'm[' -     .
(\w*)	-   .

  @dirs  ('usr', 'local', 'perl')


''
	 .  .    
\'  \\    '  \ .

:
	print q#.#;	#  .

	print 'O\'K';		# O'K

qq//
""
	 .

:
	$var = 13;
	print "\$var = $var";

:
	$var = 13


``
	      
	 .

:
	print `date`;

:
	Thu Nov 14 13:36:49 MSK 1996


	    -   
	.

:
	print qw/  !/; # ('','','!')

:
	!

  :
	use POSIX qw( setlocale localeconv )
	@EXPORT = qw( proc1 var );


	        .
	     false (0).
        ( =~  != )
   $_ .
    '/'    (')
         
 .

:

	e	-     .
	g	-  .
	i	-    
	m	-  
	o	-    
	s	-  
	x	-   

 '/'     - 
 .

:
	$var = "12345"; #  
	$var =~ s/1/0/; #  '1'  '0'.  02345
	$var =~ s(5)(.); #  '5'  '.'  0234.

       
   .

	$var =~ s/\d*//;   .  '.'

	$var =~ s///g; #   ''  ''.  '.'

	$var = "12 34"; #  

	$var =~ s/(\d\d) (\d\d)/$2 $1/; #   .  '34 12'.



y/1/2/cds

	    "1"   
 "2".  -    .  
=~  !=     $_.    
sed  tr   'y'.

:
	c	-  "1"
	d	-      .
	s	- ""   .

   /d 2    .
   2   1    1
 .  2 - null    
  .      
        
 .

:
	$s = "hello";	#  

	$s =~ tr/a-z/A-Z/;	#     . 
				# 'HELLO'

	$s = 'Hel....lo';
	$s =~ tr/a-zA-z/_/c;	#      '_'
				#  'Hel____lo'
	$s =~ tr/_/ /s;		#  '_'  ' '  .
				#  'Hel lo'
	$s =~ tr/a-zA-Z /a-zA-Z/d; #    .  'Hello'

          1  
  .




     -.   
  '`' - .      
        ""
.        ,
   -    -  .
      $? .

      '<>'.
 <>      .  
 ''         
 open().       
  '\n' -  ,      
      .
        
   false.     
    $_.     STDIN -
 .

:
	while(<>) { print; }; #      STDIN

  '<>'    .   
       , 
        
.
        
       
 .       
       
-       .

:
	while(<*.pl>) { print;}; #     ls *.pl

	@files = <*>;	#  @files     

  : @files = glob("*"); ..    
.




         .
    '\' ,   ,
     ,  
       
 .



       , 
  :

	use integer;

      
  ,       
    :

	no integer;



                
   :     
.          
',' - .           
()  ,        .   
           
 .
                 
                 
      .  
           'LIST'  
       .
             
      "  "      
                   
    .      
            .       
!

:
	print 1 + 2 + 3; #  6

	print(1+2)+3;	#  3

	print (1+2)+3;	#  3

	print (1+2+3);	# 6

           
     -  c    
.

 :

	       !

          .
       .  
      
 .       .



	-X  
	-X 
	-X

 ,  'X'     .
      -    
 .    .    
    $_.   -t STDIN.
 1  true  ''  false   
   .       
  .      .
'X'   :

	-r	     uid/gid
	-w	  -//-
	-x	 -//-
	-o	  uid ( )

	-R	     uid/gid
	-W	  -//-
	-X	 -//-
	-O	  uid

	-e	 
	-z	
	-s	 

	-f	 
	-d	
	-l	 
	-p	pipes ()
	-S	socket ()
	-b	  
	-c	-//-  -//-
	-t	  - tty

	-u	  setuid
	-g	-//- setgid
	-k	-//- sticky

	-T	 
	-B	

	-M	""       
	-A	   
	-C	    inode




          



	     . 
  accept().    false  
.



	  SIGALARM  
    .   
      .
    .



	  Y  X    -pi  +pi.



	   .  
 bind.  true     false .
 -   .


	    (binary)  .
      CR LF   LF,
   LF   CR LF.


bless 

	      
 .         
.       .
      
   -.


caller
	    .
   true     
  eval()  require()  false - .
    ($package, $filename, $line)

	$package -  
	$filename -   
	$line -      .

     :

	($package, $filename, $line, $subroutine, $hasargs, $wantargs)
  ""    .

	$subroutine -  
	$hasargs -  
	$wantargs -  
    DB    
.      @DB::args.



	    . 
     "" .
 true     false - .



	       .
    -  ,   .
      .

:		chmod 0666 'f1', 'f2', 'f3';


chomp 
chomp
	       $/.
  'LF'.    .
       $_.
        
    .


chop 
chop
	   chomp   
  .



	 ""  ""  .
  -   ,    
   .
  -       
 ,        
 "" .


	     .



	 ""  .
"" -         '/'.


	    .   
        ..  
    open().



	    opendir().



	   .   
  connect().  true   
 false  .


	   .



	 .   crypt().



	      .



	       .
          
    dbm, ndbm, sbdm, gdbm  Berkeley DB.   
 ()    .    
       ( ).
     AnyDBM().


	 true    ()
 false  .     
,     , 
  ,    ..
       
,      
.      
         
  .


	   .   
       .
    $ENV{} -  .
       -   
 .


	      eval() 
     STDERR   
     $!.  $!  0
   ($? >> 8).    0    255.
   eval()       $@
 eval()    .  
      .
       '\n'  
        
    .


	   .   
  .    
BLOCK         
.



	   .


	       .
      .
    use()  require() 
     .


	 ""  .  
   undump    
       .
      
goto .      .
!        
     .


	 2- .   - 
 -    . 
""      .
       
.


eof()
eof
	 1      
    .    
   .   
      .
        .
   eof()    
while(<>)       
.  eof(ARGV)  eof   
   .


eval 
	       .
        
    .
       
 return.      
 die       $@
   .      $@ 
 .       $_.


	      
 .      
  system().     
 1         1
    execvp()    .
        
       
  /bin/sh -c   .
         
  execvp()   .
! exec()  system(0)    /
    $|  
  .


	 true     
     .


	     .


	 e (  )  
.


	   fcntl().  
  use Fcntl;


	      .


	  flock()


	  fork().  pid   
 0       -  .


	  .    
 write.    .


	    format. 
   .     $^A
 write     ,    
    .  format   
formline    ,  formline   
.     '~'  '~~'  
       
     .


getc
	      .
      STDIN.    
 .


	  login   /etc/utmp
        
""  getpwuid().


	    .


	     PID. 
     .



	 PID  .


	   ,  
 .



getpwnam NAME

getgrnam NAME

gethostbyname NAME

getnamebyname NAME

getprotobyname NAME

getpwuid UID

getgrid GID

getservbyname NAME, PROTO

gethostbyaddr ADDR, ADDRTYPE

getnetbyaddr ADDR, ADDRTYPE

getprotobynumber NUMBER

getservbyport PORT, PROTO

getpwent

gethostent

getnetent

getprotoent

getservent

setpwent

setgrent

sethostent STAYOPEN

setnetent STAYOPEN

setprotoent STAYOPEN

setservent STAYOPEN

endpwent

endgrent

endhostent

endnetent

endprotoent

endservent

	      .
     :

($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpw*

($name, $passwd, $gid, $members) = getgr*

($name, $aliases, $addrtype, $length, @addrs) = gethost*

($name, $aliases, $addrtype, $net) = getnet*

($name, $aliases, $proto) = getproto*

($name, $aliases, $port, $proto) = getserv*

      -   
  .
 $members   getgr    
 .
@addrs  IP        .
  : ($a, $b, $c, $d) = unpack('C4',$addr[0]);



	     .


	  .


	      '*'
   ls.


	     time()  
 .
   :

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=gmtime(time);


goto 
goto &
	   .    
        
  foreach  ..
      .

:
	goto ('1', '2', '3')[$i];

  $i = 0    '1', $i = 1  '2'  ..

  (goto &)  ""  
    .  
       
    -    .



grep , 
	       .
 $_   .
        true.
      true.


	     
   .


	     import,   
       
 .    use().


index , 
	      
   .     
   .     0  
     $[.   
       1.   -1.

int 
           .


	   ioctl().   
 : require "ioctl.ph";


	       
    .


	    .  
 -  .   
   each .


	  ( )   
.      .


last
	  break  .    
  .       .
 continue  .


	     .


	     .


	   .


	  NEWFILE    OLDFILE.


	  listen().


	      
  .       
    .  
 my().


	 9-   
time   .  :

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);


	   .


lstat 
	      stat()   
     .


	 .   ""


map , 
	       .
  .


	     . 
1    0  .


	  msgctl() System V


	  msgget() System V


	  msgsnd() System V


	  msgrcv() System V


	    .
          .


next
	 continue  .      .
     continue    .
   -     .


	   .


	     .


open 
	    .  "" - 
     .   ()
          .
     '<'    
  (  ).  '>' -  .
 '>>' -   . '+>'  '+<' -  
    .
      '|'    
      ().
 '-' -   (STDIN), '>-' -   (STDOUT).
  true    false - .

	  ()    ">&"  
       .
 '&'    '<', '>>', '+>', '+>>'  '+<'.
     .
  "<&=N"  N -,   
fdopen().
  "|-"  "-|"   "" (fork) 
   .      
(PID)     0 -  .  
/      
/ .     /.
       
      $?.
            .



	      
 readdir(), telldir(), seekdir(), rewinddir()  closedir().
 true  .


	 ascii    .


	      .
 -        
.

	A	-  ,  .

	a	-  ,  0 .

	b	-   (  )

	B	-   (  )

	h	-   (   - )

	H	-   (  )

	c	-   

	C	-   .

	s	-   ( )  .

	S	-    .

	i	-  ( )  .

	I	-   .

	l	-   (4 )  .

	L	-    .

	n	-   "" .

	N	-   "" .

	v	-   "VAX" .

	V	-   "VAX" .

	f	- single float.

	F	- double float.

	p	-     0.

	P	-      .

	u	-  uuencode.

	x	- -

	X	-  .

	@	-   .

        .
     'a', 'A', 'b', 'B', 'h'  'H',
      .
 '*'      .
 'a'  'A'        
   -   ( 
  'A'    ,   'a' - ).
 'b'  'B'      .
    'h'  'H'    ().
'P' -       .
    (floats  double)  
        
   . ,    
  (double)     
 'f'    .
      .

:

	print(pack("ccc",65,66,67)); #  ABC

	print(pack("A4A3","ab","cdefg")); # "ab  cde"

	print(pack("a4a3","ab","cdefg")); # "ab\0\0cde"


	  pipe().


	     .
    1.     
.        @ARGV
    @_  .


	    m//g .


print 
print
	      .  true
 .       
        
    STDOUT (    select()).
       $_.
        
 select().
  print    ,    
      ..   
 .      .
   -      
     .


printf 
	  "print  sprintf()".
      printf()    .


	     .
      .


qq//
qx//
qw//
	  .   .


	     
  .


rand
	      0  .
   -  0  1.  
   srand().


read , , 
	        .
      
.       . 
         .


	       
opendir().       
.        
      .


	   .  
  .


	   .   recvfrom().


redo
	        
continue.        
.


	 true      - false.
     . 
  :

	REF, SCALAR, ARRAY, HASH, CODE, GLOB

  -       .
 ref()   typeof().


	 .  1     0.


require
	  - ,     
    .   -   
       .
      true.
    1;
         ".pm"
       ,  
        
require   use().


reset
	    continue  
      .
    .  
     '-'.
       
.      
??   .  
  .

:
	reset 'a';	#    
			#  'a'
	reset 'a-z'	#     .

 : 'A-Z'    ..
   @ARGV  @ENV.


	     .  
       
   .


	      
    .   
     
.


	    
      readdir().


rindex , 
	  index ,    
   .   ,  
  .


	        .
 1    0   .    $!
  (errno).




	      
.       
    ..   
   .


	      .
   0 -    ,   1 - 
 , 2 -   .  1  
 0 - .


	      
   readdir().  
    telldir().


select
	   -  
   .     
print  write       
   select.      
     .

select RBITS, WBITS, EBITS, TIMEOUT
	  select()


	  semctl()  SYSTEM V.


	  semget()  SYSTEM V.


	  semop()  SYSTEM V.


send SOCKET, MSG, FLAGS
	   .   send().


	   PGRP    PID
	0 =   .


	  PRIORITY   WHO
  WHICH.


	  .  
 .


shift
	       .
     .  
 -   @ARGV   
 @_  .


	  shmctl() System V


	  shmget() System V

shmread ID, VAR, POS, SIZE
shmread ID, STRING, POS, SIZE
	       System V.


	    HOW.


	    .


sleep
	      
    .   
  SIGALARM.    .


	       SOCKET.


	 ""     DOMAIN.
 true    false - .


sort  
sort 
                   
.      .  
           
 .
          , 
               
.       .  
            
      $main::a  $main::b. 
                
 .


splice , , 
splice , 
	        .
   .   .
          .


split //, 
split //
split
	 , ,      .
       ,
     @_ (    
 @_    ??)
       $_.
      .
      .   
    .   
    .
         
  .
      .

:
	($a, $b, $) = split(/ /, "   ",3);

 $a = '', $b = ''  $ = ' '

      - 
        ,
      .

:

        @a = split(/([,.])/, ",.");

 @a = ("", "," ,"", ".", "")


	     
 sprintf()  .


	   .


	      
 rand.      
 .


stat 
	 13     
    .    :

($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
$blksize,$blocks) = stat($filename);


	$dev	-  
	$ino	-  i-
	$mode	-  
	$nlink	-  
	$uid	-  
	$gid	-  
	$rdev	-  
	$size	-    
	$atime	-   
	$mtime	-   
	$ctime	-    
	$blksize -    
	$blocks	-    .

   '_'    
 stat().


study
	   . 
        
    .
   :
   (    
 $_)       .
       
     .
       
           .


substr , 
	       
.         .
         .


	       ..
   .  1    0 - .


	  .    - 
     -  .
       .
   .
  ,    .     
   .    
     .   
 14 .   .


sysread , , 
	         
  read().     
     .


	      "exec "    
  fork()      
 .     wait().
      
 256.


syswrite , , 
	        
  write().     
  .


tell
	      .
       .


	      .
      
 seekdir().


	  .  -  
new   (TIESCALAR, TIEARRAY  TIEHASH).
       
     .
!    keys()  values()  
     .

      
 :

	TIEHASH classname, LIST
	DESTROY this
	FETCH this, key
	STORE this, key, value
	DELETE this, key
	EXISTS this, key
	FIRSTKEY this
	NEXTKEY this, lastkey

 :

	TIEHASH classname, LIST
	DESTROY this
	FETCH this, key
	STORE this, key, value
	[others TBD]

 :

	TIEHASH classname, LIST
	DESTROY this
	FETCH this, key
	STORE this, key, value


	     1  1970 
00:00:00 UTC.     .


	 4-   :

	($user, $system, $cuser, $csystem) = times;

:

	$user	-      .

	$system	-    .

	$cuser	-  -  .

	$csystem -   .

tr///
	 .    "".

truncate , 
truncate , 
	   .


	       
 .


	       
 .


umask
	  umask    .
    .


undef
	   . 
   ,    .
   .


	    .  
 .     
       -U.


	  pack().   
     .   
    .   
   pack().
 '%'        
   .   16 .


	     tie().


	 shift.   
  .


use 
	     
 .     
    .      .
  :

	BEGIN { require ; import  ; }

        .


	       .
        
  .
   .


	      .
      .


	       .


	   . 
PID     -1    .
     $?.


	      PID.
  PID    -1    .
     $?.


	 true     
  false -  .


	     STDERR 
 die(),     .


write 
write
	      
format.         .
 -     select(),  
      $~.
   .     
     " "  
     .
         
    "_TOP".    
   $^.    
   $-     0  
 .       "".


	 .   "".



         
()     ().
     :

	sub ;	#  .  .

	sub  ();       .

	sub  ;	#   .

	sub  () ; #  ,   .

      :

	$ = sub ;

      :

	use  qw(1 2 );

 :

	( );	#  '&'   .

	 ;	#    .

	&;		#   @_

      @_.
 $_[0] -  , $_[1] -   ..
 @_ - ,      
   .
   -   .
       .   
   return().

     '&'  
.     
    .



        
      my().

      .

my()  private     ,
,  eval()  do/require/use . Private 
 auto   .

:

	#   .

	print fact(3);  #   3*2*1

	sub fact	#  .
	{ my $m;                # private    local !
	$m = $_[0];
	return 1 if $m <= 1;
	return($m * fact($m -1));
	}

    private  :

	my() = ;

      :

	my($m) = $_[0];


  local.

    private  -   
. private     
()  local - .    
       .
  local()      
         
 .




      
  .     :

			 

	sub mylink($$)		mylink $old, $new
	sub myvec($$$)		myvec $var, $offset, 1
	sub myindex($$;$)	myindex &getstring, "substr"
	sub myreverse(@)	myreverse $a, $b, $c
	sub myjoin($@)		myjoin ":",$a,$b,$c
	sub mypop(\@)		mypop @array
	sub mysplice(\@$$@)	mysplice @array, @array, 0, @pushme
	sub mykeys(\%)		mykeys %{$hashref}
	sub myopen(*;$)		myopen HANDLE, $name
	sub mypipe(**)		mypipe READHANDLE, WRITEHANDLE
	sub mygrep(&@)		mygrep { /foo/ } $a, $b, $c
	sub myrand($)		myrand 42
	sub mytime()		mytime

:
	\''	-    ''

	'@'  '%'	-     

	'$'		- 

	'&'		-  

	'*'		-    

	';'		-      .




        
     ,     
 .        
 '*'    'type glob'    
 '*'  "  ".  '*' 
  "  ".
   '*'    ..    
        
 $_[0].




      
.        
  .

        :

	use subs '1', '2' ....;

      .




         
   .     
  'AUTOLOAD'        
  $AUTOLOAD     
.       .



             .     
       .  
         .  
 :

	packages _;

              .  
       main.          
  '::'   .
 :

	$main::var1	-    .

	::var1		-   .  main  .

	$1::var1	-    '1'

	$1::2::var1 - 2    1.

       '_' 
    .    
  main.
   STDIN, STDOUT, STDERR, ARGV, ARGVOUT, ENV, INC  SIG
     .



       ()  
     "::".   
    %main:: ,  'mod1'  %mod1::
 ..   *     ''
    .

:
	*pi = \3.14159;

  $pi -       .



 -       
,   -  .    
  BEGIN  END.     
sub  .

 BEGIN      ..  
       .  
  BEGIN.        
.

 END      .. 
  .     END
        .




      .  
    .    
 ,     @ISA  
   .     .



        
  ,     
   ,     
:

	package _;	#          '.pm'
	require Exporter;	#     
	@ISA = qw(Exporter);	# -//-
	@EXPORT = qw(func1 func2) #   .  !  !
	@EXPORT_OK = qw( $ @ ); #   ,   ..  
	{  #   
	.....
	sub func1
	........
	sub func2
	........
	1;
	}

    ".pm"      
 .     @INC    
"/usr/local/lib/perl/".

    :

	use _;

       .




       
   pragma  (   )
  .

Pragma .

   :

	use ;

    

	no ;

 .



diagnostics
	   .

integer
	  .

less
	   .


overload
	  .

sigtrap
	   .

strict
	   "" .

subs
	   .


 .

AnyDBM_File
	      .

AutoLoader
	       .

AutoSplit
	   .

Benchmark
	   .

Carp
	  .

Config
	   .

Cwd
	    .

DB_File
	     Berkley DB.

Devel::SelfStubber
	  .

DynaLoader
	   C.

English
	    .

Env
	   

Exporter
	 /  .

ExtUtils::LibList
	  .

ExtUtils::MakeMaker
	   Makefile

ExtUtils::Manifest
	      MANIFEST

ExtUtils::Mkbootstrap
	     DynaLoader.

Fcntl
	     Fcntl.h

File::Basename
	   .

File::CheckTree
	    .

File::Find
	    .

FileHandle
	      .

File::Path
	/ .

Getopt::Long
	  .

Getopt::Std
	  .

I18N::Collate
	   .

IPC::Open2
	     .

IPC::Open3
	   , ,   .

Net::Ping
	   .

POSIX
	   IEEE Std 1003.1

SelfLoader
	    .

Socket
	        socket.h

Test::Harness
	   .

Text::Abbrev
	    .

       .




                      
      CPAN.      
       
.
             ,    ,
    ,    ,    ,
-,    ,      CGI
   Web          .  
 CPAN      .



              
.     format     ,
  ,        
 .     write()  
     .

    :

	format  =
	FORMLIST
	.

          format  
 '.'   .

 '' -   ,        .
 ''      - STDOUT.

FORMLIST -   .    :

	1. .    '#'.

	2.    (picture).

	3.    .

 -       " "  
    .   
  '@'  '^'.
       
 ,      .
        
        
   .

        :

	">>>>"	-     .

	"<<<<"	- -//-  .

	"||||"	- -//-  .

	"####.###"	-    .

	"@*"	-  .    .

     .

 '^'      .

:
	"^####"	-     .

  :

	"^<<<<<" -    ,  
        
      .

:

#!/usr/local/bin/perl
#
#	   
#
$ = "  ";

$_ = " ";

$ = ", . ,  38";

$ = "  !     
         , 
      .";

format STDOUT =

	                        
----------------------------------------------------------------------
: @<<<<<<<<<<<<<<<<<<<<<<<<<<  | ^|||||||||||||||||||||||||||||||
      $,				$
                                   | ^|||||||||||||||||||||||||||||||
      					$
 : @<<<<<<<<<<<<<<<<<<<<<<<  | ^|||||||||||||||||||||||||||||||
      $_,				$
                                   | ^|||||||||||||||||||||||||||||||
      					$
:@<<<<<<<<<<<<<<<<<<<<<<<<<<  | ^|||||||||||||||||||||||||||||||
      $,				$
                                   | ^|||||||||||||||||||||||||||||||
      					$
                                   | ^|||||||||||||||||||||||||||||||
      					$
                                   | ^|||||||||||||||||||||||||||||||
      					$
----------------------------------------------------------------------
    38
.

write();	#  .
exit 0;		#  


:


	                        
----------------------------------------------------------------------
:       |     !
                                   |        
 :                |      
                                   |       
:, . ,  38   |    ,  
                                   |      
                                   |         .
                                   |
----------------------------------------------------------------------
    38

 :

	$~	-   .

	$^	-   .

	$%	-  .

	$=	-   .

           
   :

	use FileHandle;	#    

	format_name  _; #   .

	format_top_name  _; #   .

	write();	#  .


 ''       open();

          (
    )   format_name.



      .
      '-d'    
  .      
,      , ,
    -    .
       
  .

 .

	h	-    .

	T	-   

	s	-     .

	n	-    .

	r	-     .

	c	-      .

	c 	-       .

	<CR>	-    n  s.

	l min+incr	-  incr+1      min.

	l min-max	-     min  max.

	l 	-     .

	l	-    .

	-	-    .

	w 	-   .   .

	l 	-    .

	//	-     .

	??	-      .

	L	-       .

	S	-    .

	t	-    .

	b  [ ] -   .

	b  [  ] -     
       .

	d	-   .

	D	-    .

	a   -   (   
  . "" -   .

	A	-   .

	< 	-     .

	> 	-     .

	V  [] -      
 . !  '$'  .

	X []	-     V ,     .

	! 	-    .

	! -	-      
			 .

	H - n	-  n   .

	q  ^D	-   .

			-   .

	p 	-   .

 BEGIN   ,     
:
	$DB::single =1;

  .       
 .



            
 "Perl Programmers Reference Guide".

   :

	Programming Perl (the Camel Book)

	Learning Perl (Llama Book)





	comp.lang.perl.announce -    .

	comp.lang.perl.misc -     .

	comp.lang.perl.modules -  .

	comp.lang.perl.tk -   Tcl/tk.




	http://www.perl.org
                                -  -

	http://www.ora.com
                                -     O`Reily

	ftp://ftp.perl.com
                                -  FTP 

	http://franz.ww.tu-berlin.de/modulelist


Last-modified: Sun, 02 Jul 2000 22:34:02 GMT
: