DanielSpaniel has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
This isn't a problem so much as me trying to understand something, but I hope someone might be kind enough to help explain.
So, I have some code, which was sourced from elsewhere (it's from a Mojo example), which uses a callback, but I don't really quite get the idea of callbacks, and particularly I don't understand the syntax.
$ua->get($url => \&get_callback);So, sure enough there is a subroutine called get_callback, but I don't really understand what's happening. I did find an O'Reilly doc on callbacks, but the syntax was different.
sub get_callback { my (undef, $tx) = @_; .... .... }
I don't really get the first line of the get_callback routine either, when nothing appears to be being passed across
If someone might explain in kiddie-steps what's happening, and why, then it would be much appreciated. Many thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to Understand Callback(s)
by holli (Abbot) on Nov 23, 2017 at 22:33 UTC | |
by Laurent_R (Canon) on Nov 23, 2017 at 23:47 UTC | |
by DanielSpaniel (Scribe) on Nov 24, 2017 at 01:17 UTC | |
|
Re: Trying to Understand Callback(s)
by ikegami (Patriarch) on Nov 23, 2017 at 22:53 UTC | |
|
Re: Trying to Understand Callback(s)
by GrandFather (Saint) on Nov 23, 2017 at 23:22 UTC | |
|
Re: Trying to Understand Callback(s)
by shmem (Chancellor) on Nov 24, 2017 at 00:29 UTC | |
by DanielSpaniel (Scribe) on Nov 24, 2017 at 01:14 UTC | |
by Laurent_R (Canon) on Nov 24, 2017 at 21:32 UTC | |
|
Re: Trying to Understand Callback(s)
by Anonymous Monk on Nov 23, 2017 at 23:25 UTC |