|
|
| Think about Loose Coupling | |
| PerlMonks |
Re^2: Label makes a sub to return empty list -- "secret"? documented?by LanX (Saint) |
| on Sep 11, 2025 at 13:44 UTC ( [id://11166198]=note: print w/replies, xml ) | Need Help?? |
|
to make this clearer for beginners:
FWIW using a label can have unwanted global side-effects, because a nested sub could have a goto _; some experiments:
Cheers Rolf
UPDATE¹) jdporter pointed out: you say "last statement", but you mean "last expression evaluated". Not the same thing! well yes not every statement is an expression leading to a value, and it's the last in the current code flow which counts (think if/else), not in the sub. That's what the docs say: If no return is found and if the last statement is an expression, its value is returned. If the last statement is a loop control structure like a foreach or a while, the returned value is unspecified. The empty sub returns the empty list
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||