Re: Problem with my code for passing block

2022-01-11 Thread demerphq
On Tue, 11 Jan 2022 at 11:35, Jan Kasprzak wrote: > demerphq wrote: > : On Tue, 11 Jan 2022 at 10:18, Yamadaえりな wrote: > : > : > So, I would like to ask another question: > : > Is it safe to pass function reference to the caller (mostly it's the > : > method instantized from a class) in

Re: Problem with my code for passing block

2022-01-11 Thread Jan Kasprzak
demerphq wrote: : On Tue, 11 Jan 2022 at 10:18, Yamadaえりな wrote: : : > So, I would like to ask another question: : > Is it safe to pass function reference to the caller (mostly it's the : > method instantized from a class) in mod_perl development env? : > Or should I avoid using this style? : >

Re: Problem with my code for passing block

2022-01-11 Thread demerphq
On Tue, 11 Jan 2022 at 10:18, Yamadaえりな wrote: > So, I would like to ask another question: > Is it safe to pass function reference to the caller (mostly it's the > method instantized from a class) in mod_perl development env? > Or should I avoid using this style? > Nothing wrong with passing

Re: Problem with my code for passing block

2022-01-11 Thread Yamadaえりな
So, I would like to ask another question: Is it safe to pass function reference to the caller (mostly it's the method instantized from a class) in mod_perl development env? Or should I avoid using this style? Thanks.

Re: Problem with my code for passing block

2022-01-11 Thread Yamadaえりな
Thanks for all your help. Yes I have made the mistake to think {} is a code reference in perl. 私はすでに理解していますありがとう On Tue, Jan 11, 2022 at 5:10 PM Jacques Deguest wrote: > Yamada-san, > > The value you pass to 'run' is not a code reference, but an hash > reference, i.e. '{}' > > A code reference

Re: Problem with my code for passing block

2022-01-11 Thread Jacques Deguest
Yamada-san, The value you pass to 'run' is not a code reference, but an hash reference, i.e. '{}' A code reference would be: 'sub{}', so do '$obj->run( sub{ "hello world"} );' instead. Jacques On 2022/01/11 17:51, Yamadaえりな wrote: Good afternoon, Can you help check my problem with this?

Re: Problem with my code for passing block

2022-01-11 Thread demerphq
On Tue, 11 Jan 2022, 16:53 Yamadaえりな, wrote: > Good afternoon, > > Can you help check my problem with this? > > $ cat t1.pl > use strict; > > package Myclass; > > sub new { > my $self = shift; > bless {},$self; > } > > sub run { >my $self = shift; >my $block = shift; >&{$block};

Problem with my code for passing block

2022-01-11 Thread Yamadaえりな
Good afternoon, Can you help check my problem with this? $ cat t1.pl use strict; package Myclass; sub new { my $self = shift; bless {},$self; } sub run { my $self = shift; my $block = shift; &{$block}; } 1; package main; my $obj = Myclass->new; $obj->run( { "hello world"} );