develooper Front page | perl.perl5.porters | Postings from January 2011

Re: Time to update

Thread Previous | Thread Next
Tom Christiansen
January 30, 2011 11:11
Re: Time to update
Message ID:

> The only exception for non-core-like functions that I find
> sensible is using the empty prototype for constant functions:

>   $ perl -wE 'sub FOO {3}; say FOO+1'
>   3

>   $ perl -wE 'sub FOO () {3}; say FOO+1'
>   4

> Without the prototype the "FOO+1" is parsed as "FOO(+1)"
> instead of "FOO()+1".

Even that is only if you just happen to have a forward 
declaration of the function.  Otherwise it's a filehandle 
literal in the dative slot:

    % perl -wE 'say FOO+1; sub FOO {3}'
    say() on unopened filehandle FOO at -e line 1.

    % perl -wE 'say FOO(+1); sub FOO {3}'

    % perl -wE 'say FOO()+1; sub FOO {3}'


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About