idea for use of a & prototype

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Using & as prototype for the first argument of a subroutine means the
first argument pass to this subroutine has to be a reference to an
anonymous subroutine and the 'sub' keyword may be omitted from the
definition. I didn't use this for anything (except 'pseudo loop
examples') so far, however, an idea I consider rather neat is using at
as follows:

    until_success {
    exit(1) if rand(100) >= 50;
    $rq = make_request($srv_info);

[the code in the subroutine is obviously just for testing]

Ultimatively, this will end up connecting to an Apple DEP server in
order to retrieve a (so-called) session authentication token which comes
with all the usual perils of network programming so the 'communication'
part should be retried (with some randomized delay) unless the process
is stopped by admin intervention before it succeeded (not supposed to be
used interactively).

The until_success subroutine implements the 'try this, wait for some
time if it didn't work and try again' part while the productive code
will end up in the block.

Site Timeline