Hi David,
Yes, an anonymous function.
Tried as you suggested (without '=>') but still getting an error:
Mojo::Reactor::Poll: I/O watcher failed: Can't use an undefined value as a
subroutine reference at $cb->($tx->res->body)
Can you guide me what's wrong now?
вторник, 5 апреля 2016 г., 19:46:33 UTC+4 пользователь David Stevenson
написал:
>
> What are you trying to pass to api_func1? An anonymous function?
>
> So did you mean api_func1(sub{…})
>
> as opposed to
>
> api_func1(sub =>{…}); # Extra => ?
>
>
> On 5 Apr 2016, at 16:39, Pavel Serikov <[email protected] <javascript:>>
> wrote:
>
> Thanks, Dominique, I was inattentive. But problem still not solved. Not I
> have an error
>
> Global symbol "$json" requires explicit package name
>
>
> at string marked yellow.
>
> api_func1(sub => {
> my ($self, $json) = @_;
> $c->render(json => $json);
> })
>
> What could be wrong?
>
> Also tried
>
> api_func1(sub => {
> *my $json = shift;*
> $c->render(json => $json);
> })
>
> But same error.
>
>
>
>
> вторник, 5 апреля 2016 г., 19:19:47 UTC+4 пользователь Dominique Dumont
> написал:
>>
>> On Tuesday 05 April 2016 08:14:36 Pavel Serikov wrote:
>> > But I got a syntax error at string marked orange. What is wrong?
>>
>> $cb is a sub reference and must be called with '->':
>>
>> $cb->($tx->res->json);
>>
>> HTH
>>
>> --
>> https://github.com/dod38fr/ -o- http://search.cpan.org/~ddumont/
>> http://ddumont.wordpress.com/ -o- irc: dod at irc.debian.org
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]
> <javascript:>.
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.