/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/languages/perl/perl.modules

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
���������:
 
2
----------
 
3
package name::subname ( �������� File::Find )
 
4
... functions ...
 
5
1;
 
6
__END__
 
7
Desription subspace
 
8
 
 
9
* 1; ����������� ;)
 
10
* ��� ������ ������ ������ ���-������ � "name/subname.pm"
 
11
 
 
12
������� ������� & etc:
 
13
----------------------
 
14
* ������ @EXPORT ������ ��������� ���, ��� ����� �������������� �� ���������
 
15
* ������ @EXPORT_OK �������� ���, ��� ����� ���� ������������� � ������� 
 
16
  ����������� "use name::subname $varname"
 
17
 
 
18
����������:
 
19
-----------
 
20
name::subname::varname - ���������� ������ name::subname (������� �����)
 
21
MAIN::varname - ���������� ���������� (��� $::varname)
 
22
 
 
23
�����������:
 
24
------------
 
25
require name::subname;          �� ���� #include
 
26
use name::subname;              ���������� �� ����������� ��� ��� ������������
 
27
                                �� ������ ���������� � ����� �������������
 
28
                                ����������(����� ���� ����� MAIN scope). ���
 
29
                                ����� ���� ������� ��� ���������� � ���� package
 
30
                                ��� ����������� ��������� �����������:
 
31
                                use name::subname qw(var1 var2 func1 func2...)
 
32
 
 
33
 
 
34
��������������� ����������� �������:
 
35
------------------------------------
 
36
* ����� �������� �������������� �������, ���������� ������ ������� ������� � 
 
37
  ��������������� ������.
 
38
* ��� �� �������������� ������� �� ���� ���������:
 
39
    package MyName
 
40
    require Exporter;
 
41
    *import=\&Exporter::import;
 
42
    @ISA = 'Exporter';
 
43
    @EXPORT_OK = 'glob';
 
44
    sub url()
 
45
    ...........
 
46
    use MyName 'GLOBAL_glob';
 
47
* �� �������� ������� ��� ���� ����� ������� � ������� CORE::fname
 
48
 
 
49
 
 
50
���� ������:
 
51
------------
 
52
*   ����� � Perl �� ����� ����������, ��� �� ���� ��������� ������(���������
 
53
    � ����). ����� ����������/������/���(��������������� ���) c ������� �������
 
54
    bless ����������� �������.
 
55
    sub TipaConstructor {
 
56
        this=shift(@_);
 
57
        bless {"Var1" => value1,"Var2" =>Value2"};
 
58
    } 
 
59
        ���, ��� � Perl �� ������� ������������ "last expression evaluated",
 
60
        �� ����� ���������, ��� ��� ��� ���������� ���.
 
61
    
 
62
    ������ ���������� � ����������� ���������� ��� ������. ������ ��� �������
 
63
    ������, ���� ����������� ������, ��� 
 
64
            $object=name::subname->TipaConstructor($a,$b),
 
65
    �� ������������� ������ ���������� ���������� ��� ������(������������ � 
 
66
    �������). � ����:
 
67
            $object=name::subname::TipaConstructor("class_name",$a,$b);
 
68
    �� ��� ��� � ��� ���� ���������� �������(��� ������� ����) ��� ���-�� ��� 
 
69
    ��� ����������� ����� � ������������...
 
70
    
 
71
*   ��� ���� ������� ����������:
 
72
        object->func(p1,p2) <=> func object p1,p2
 
73
        � ��������� �����������: $object=TipaConstructor name::subname $a $b
 
74
        �������� � ������������� �������� $obj=TC name::subname($a,$b)
 
75
 
 
76
*   ��������� ������� bless ���������:
 
77
            bless $objref [$classname];
 
78
        objref - ��������� �� ���, ������ ��� ��� ���-�� ��� ����� ��������
 
79
        classname - ��� ������, ���� ������� perl ��� ���-���� ��������� ;)
 
80
 
 
81
*   ��� ������� ������, ��� ��������� �����������(������ _��������_ ��� ����
 
82
    ��������� ������� bless) ��������� �������� ������. ��� �� �������
 
83
    ����������� ������ '@ISA', � ������� ��������� ����� ������ �������,
 
84
    ������� �������� ������ ������. ��-���� ��� ������� ����������� ������
 
85
    ������� ������������� � @ISA �������� �������� ��������. (The classes
 
86
    accessible through @ISA are known as base classes of the current class)
 
87
    
 
88
    ������� ���� ���� ��� ���������� ������� �������������, �� � Perl� 
 
89
    ����������� ������ ������. � ������ ������������ ����������� workarround, 
 
90
    �� � ��� ���� ��������� �� ����. 
 
91
 
 
92
*   ������ ����� ���������� ����� ���������
 
93
    1. ���������: $object->method($a,$b)
 
94
        � ���� ������ ������ ���������� ���������� ������ �� ������� ������ (��
 
95
        ������� ���� ����� $object � ����������), � ����� ��� ������ $a � $b.
 
96
    2. �����������: name::subname::method($a,$b)
 
97
        ����� ������ �� ������ �� ����������, � ���������� ������ $a � $b
 
98
 
 
99
    ���������� ������ ������ � ���� Perl� ������� �� ������ ������ �������, 
 
100
    � ����� ������� ��������� ����� $object->name2::subname2::method2($a,$b),
 
101
    ��� ����� ������������: name2::subname2::method2($object,$a,$b) -
 
102
!   �� ���� ���� $obj-><something>($a,$b) <=> <something>($obj,$a,$b) � ���!!!
 
103
    �� ��� ���� ��� ��� �������� ��� � ��� � �� ����� ;)))
 
104
 
 
105
*   $method_name="method"; $object->$method_name(...) - ���� ��������
 
106
 
 
107
*   ������� � ������ DESTROY ����� ��������� ���� �����������. ������ ����������
 
108
    ���� ���������� ������
 
109
 
 
110
*   ���� ����� UNIVERSAL package (����������� ����� ��������, � ��������� Perl�
 
111
    ����������) ������� �������� ��������� ������:
 
112
    isa(CLASS)          1, ���� ������ blessed � �������� CLASS.
 
113
    can(METHOD)         ��������� ����� �� ������ �����, ��������� METHOD, ����
 
114
                        ��, �� ��������� �� ���� ���������, ����� ����������
 
115
                        undef
 
116
    VERSION([NEED])     ���������� ������ ������. ���� NEED ����� �� ���������,
 
117
                        ����� ������ ���� �� ������ ���������, ����� ���������
 
118
                        die!
 
119
 
 
120
*   ���������� ��� ����� ��� ������, � ����������� ���������. ��� ��� ������:
 
121
    $b=$a;bless \$a; ������ � ��
 
122
 
 
123
����������� �������(package constructors/destructors):
 
124
------------------------------------------------------
 
125
BEGIN:  ����������� � ����� ������ �������, ����� ��������� ����� ���������� 
 
126
        �����. 
 
127
        ���� ��������� ������ ������ ��� ����������� � ������� �������.
 
128
END:    �������������� ����������� � ����� �����, ����� ��� ��� ��������� 
 
129
        ����������. 
 
130
        ����������� ���� � ��� ������, ���� ���������� ������ ���������� � 
 
131
        ������� ������� die(). �� �����������, ���� ����� �������� ��� 
 
132
        �������������� �� ���-������ ������ � ������� exec().
 
133
        ���� ��������� ������ ������ ����������� � �������� �������
 
134
INIT:   ����������� ����� ����� �������� ����� �����. 
 
135
CHECK:  ����������� ����� ����� ������ ��������������, ����� �����������
 
136
 
 
137
*       ����� ������������������ ���������: BEGIN,INIT,CHECK,..execution..,END
 
138
*       ���������� "sub" � ���� ������ ����� ��������
 
139
 
 
140
������:
 
141
-------
 
142
strict          - ����� ����������� ����� ����� ������� ���������
 
143
File::Find      - ����� ������