[Moscow.pm] function ref

Nikolay Mishin mi ya.ru
29 03:22:30 PST 2011


,    ,   !

29.12.2011, 15:17, "oleg alexeenkov" <proler  gmail.com>:
> Nikolay Mishin <mi  ya.ru> ()  ϣ  Thu, 29 Dec 2011
> 15:07:45 +0400:
>
>>       -  
>> (       )
>>    ,
>>      
>>      
>>
>> !
>
>   .
>
>> 29.12.2011, 15:37, "Dmitry Karpich" <meettya  gmail.com>:
>>>  .
>>>
>>> sub create_index ($$){
>>> my ($fh, $idx_file)=@_;
>>> print "create index func\n";
>>> }
>>>
>>> my $fh = 10;
>>> my $idx_file = 20;
>>>
>>> say ' - work, but looks strange';
>>> my $index_func_name=\&create_index; # JUST &create_index, NOT
>>> &create_index() !!!!!
>>> $index_func_name->( $fh, $idx_file);
>>>
>>> say ' - much better';
>>> create_index $fh, $idx_file; # just func, don`t do that on class method
>>>
>>>    , ? :)
>>>
>>> .
>>>
>>> On Dec 29, 2011, at 1:16 PM, Nikolay Mishin wrote:
>>>> , ;))    3- ,
>>>>    ,    
>>>>
>>>> $$index_func_name->( $fh, $idx_file );
>>>>     
>>>>   
>>>> $index_func_name->( $fh, $idx_file );
>>>>  -  , 
>>>> &$index_func_name->( $fh, $idx_file ); !!
>>>>
>>>>    , ,
>>>>  
>>>> &$index_func_name->( $fh, $idx_file ); !!
>>>>
>>>>  ,   
>>>>
>>>> 29.12.2011, 15:03, "Dmitry Karpich" <meettya  gmail.com>:
>>>>>  
>>>>>
>>>>> my $ref_sub1=sub {print 'By '. $_[0] };
>>>>> sub temop_sub{ print 'Hi '. $_[0] };
>>>>> my $ref_sub=\&temop_sub; # !!!!!   sub     
>>>>> 
>>>>>
>>>>> $ref_sub->(); #  -  
>>>>>
>>>>> &{$ref_sub1};
>>>>>
>>>>> ,      Larry ,   :)
>>>>>
>>>>> 
>>>>>
>>>>> On Dec 29, 2011, at 12:48 PM, Nikolay Mishin wrote:
>>>>>> Hi MoscowPM
>>>>>>
>>>>>> my $ref_sub1=sub {print 'By '. $_[0] };
>>>>>> sub temop_sub{ print 'Hi '. $_[0] };
>>>>>> my $ref_sub=\&temop_sub();
>>>>>> $$ref_sub;
>>>>>> &$ref_sub;
>>>>>> Not a CODE reference at 11_sub_ref.pl line 5.
>>>>>> &{$ref_sub1};
>>>>>>
>>>>>>  ?
>>>>>>       
>>>>>> &{$ref_sub1}; ??
>>>>>>       
>>>>>> & - ,    $
>>>>>>   ,   
>>>>>>
>>>>>> .
>>>>>> --
>>>>>> Nikolay Mishin
>>>>>> --
>>>>>> Moscow.pm mailing list
>>>>>> moscow-pm  pm.org | http://moscow.pm.org
>>>>> --
>>>>> Moscow.pm mailing list
>>>>> moscow-pm  pm.org | http://moscow.pm.org
>>>> --
>>>> Nikolay Mishin
>>>> --
>>>> Moscow.pm mailing list
>>>> moscow-pm  pm.org | http://moscow.pm.org
>>> --
>>> Moscow.pm mailing list
>>> moscow-pm  pm.org | http://moscow.pm.org
>> --
>> Nikolay Mishin
> --
> Moscow.pm mailing list
> moscow-pm  pm.org | http://moscow.pm.org

--
Nikolay Mishin


Moscow-pm