http://qs1969.pair.com?node_id=1204174


in reply to Trying to Understand Callback(s)

\&get_callback doesn't call get_callback; it returns a reference to it. This reference will be used by get to invoke the sub at a later time (e.g. when the request succeeds or fails). When get invokes it, it will pass parameters to it.

sub get { my ($ua, $url, $cb) = @_; ... $cb->($foo, $tx); # Call the referenced sub. ... }