# New Ticket Created by James Keenan # Please include the string: [perl #77218] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=77218 >
The New York City Rakudo Star study group is working its way through the Using Perl PDF from Rakudo's github site. Working through the examples in Chapter 4, Subs and Signatures, we are puzzled by the fact that, at least *some of the time*, when you declare a subroutine *before* you call it, the sub will fail to run. When you move the sub declaration *after* the call, it works. WORKS: use v6; orderbeer('Hobgoblin', 1); sub orderbeer($type, $pints) { say ($pints == 1 ?? 'A pint' !! "$pints pints") ~ " of $type, please."; } FAILS: use v6; sub orderbeer($type, $pints) { say ($pints == 1 ?? 'A pint' !! "$pints pints") ~ " of $type, please."; } orderbeer('Hobgoblin', 1); Error message ===SORRY!=== Confused at line 3, near "sub orderb" shell returned 1 On the other hand, other subroutines work regardless of whether they are declared before or after the point at which they are called. WORKS EITHER WAY: use v6; sub announce-time(:dinner($supper) = '8pm') { say "we eat dinner at $supper"; } announce-time(dinner => '9pm'); Can you clarify? Thank you very much. kid51