![]() |
|
Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^2: Why does this compile?by karlgoethebier (Abbot) |
on Nov 25, 2024 at 18:44 UTC ( [id://11162886]=note: print w/replies, xml ) | Need Help?? |
Doh! I am somewhat surprised. I didn't think of the idea with the block. I connect block with curly brackets. But Perl is jesuitically sophisticated. From ibidem: ” In Perl, a sequence of statements that defines a scope is called a block. Sometimes a block is delimited by the file containing it (in the case of a required file, or the program as a whole), and sometimes a block is delimited by the extent of a string(in the case of an eval). But generally, a block is delimited by curly brackets, also known as braces. We will call this syntactic construct a BLOCK. Because enclosing braces are also the syntax for hash reference constructor expressions (see perlref), you may occasionally need to disambiguate by placing a ; immediately after an opening brace so that Perl realises the brace is the start of a block. You will more frequently need to disambiguate the other way, by placing a + immediately before an opening brace to force it to be interpreted as a hash reference constructor expression. It is considered good style to use these disambiguating mechanisms liberally, not only when Perl would otherwise guess incorrectly.” In this case, the entire program - or main. Thanks and regards, Karl
In Section
Seekers of Perl Wisdom
|
|