DanielSpaniel has asked for the wisdom of the Perl Monks concerning the following question:


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!