Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Why does this compile?

by choroba (Cardinal)
on Nov 25, 2024 at 17:12 UTC ( [id://11162885]=note: print w/replies, xml ) Need Help??


in reply to Why does this compile? [Solved]

Do you mean the absence of a semicolon before the __END__? Even this compiles and runs:
$nose !~/fubar/ and say "Super!"__END__

The __END__ token just tells Perl "stop reading the source right here". perlsyn says "Every simple statement must be terminated with a semicolon, unless it is the final statement in a block, in which case the semicolon is optional". This is exactly the optional case.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Why does this compile?
by karlgoethebier (Abbot) on Nov 25, 2024 at 18:44 UTC

    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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11162885]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2026-04-19 10:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.