in reply to How does this code work? (from "Perl is Unix")

run_fork and child are function calls declared with the & prototype (See perlsub: Prototypes). So, yes, they auto-subify their first argument (as though you had called run_fork(sub { ... })).

Good Day,
    Dean

Replies are listed 'Best First'.
Re^2: How does this code work? (from "Perl is Unix")
by Anonymous Monk on Nov 06, 2009 at 15:18 UTC

    Ohhhhhh. I see. Thank you for pointing that out! I've avoided using Prototypes in my own code, and had almost forgotten about them.

    FWIW, I much prefer the more explicit syntax that you gave as an equivalent example. That is, something like this seems sensible and obvious to me:

    #!/usr/bin/env perl use strict; use warnings; sub call_it { my $fn_ref = shift; &{$fn_ref}(); } call_it( sub { print "hi\n" } ); call_it( sub { print "bye\n" } );

      If you understand map { foo($_) } then this code shouldn’t give you any trouble.

      Makeshifts last the longest.