develooper Front page | perl.perl5.porters | Postings from April 2014

Re: [perl #121501] Empty code block {} causes syntax error(misparsed as anonymous hash constructor?) before 'sub'

Thread Previous | Thread Next
From:
Abigail
Date:
April 14, 2014 14:54
Subject:
Re: [perl #121501] Empty code block {} causes syntax error(misparsed as anonymous hash constructor?) before 'sub'
Message ID:
20140414145559.GB17701@almanda.fritz.box
On Tue, Mar 25, 2014 at 02:42:25PM +0000, Dave Mitchell wrote:
> On Tue, Mar 25, 2014 at 04:23:54AM -0700, Ed Avis wrote:
> > Please allow an empty BLOCK to occur before a subroutine
> > definition, just as an empty BLOCK can occur elsewhere in a program.
> 
> Can you give an example of such an empty block not being a syntax
> error?


    { }
    __END__


Although one could argue that this isn't a block (because Perl doesn't
parse it as a block, but as a hashref).

    if (1) { }

is fine too.


Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About