in reply to Re: Forward declaration of subs
in thread Forward declaration of subs

> mutually recursive subroutines ... if you want to avoid using parens.

As an illustration, the following doesn't work cause &b is unknown when &a is compiled.

Without strict b will be converted to string "b" and returned. (strict prohibits this behaviour of barewords.)

lanx@nc10-ubuntu:/tmp$ perl sub a { print "a$level "; b if $level-- }; sub b { print "b$level "; a if $level-- }; $level=5; print"\n"; a; print"\n"; b; __END__ a5 b4 a3

with forward declaration

lanx@nc10-ubuntu:/tmp$ perl sub b; sub a { print "a$level "; b if $level-- }; sub b { print "b$level "; a if $level-- }; $level=5; print"\n"; a; __END__ a5 b4 a3 b2 a1 b0

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^3: Forward declaration of subs
by BrowserUk (Patriarch) on Oct 12, 2013 at 01:47 UTC

    Better addressed to the OP.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.