develooper Front page | perl.perl5.porters | Postings from July 2020

Re: Announcing Perl 7

Thread Previous | Thread Next
Paul "LeoNerd" Evans
July 3, 2020 23:28
Re: Announcing Perl 7
Message ID:
On Fri, 3 Jul 2020 20:20:04 +0200
demerphq <> wrote:

> I want this:
> ---
> package Whatever;
> use v7;
> ---
> to not be an error. I don't want to have to write:
> ---
> use v7;
> package Whatever;
> ---

Not that it matters much to the argument, but I have just found a very
minor reason to want to `use VERSION` even before your package

Perl 5.12 added the "package NAME VERSION;" syntax, meaning you can

  package Whatever 1.23;

instead of the more longwinded

  package Whatever;
  our $VERSION = 1.23;

Perl older than 5.12 will get upset:

  $ perl5.10.1
  syntax error at line 1, near "package Whatever 1.23"
  Execution of aborted due to compilation errors.

Not a huge problem, but if you write

  use v5.12;
  package Whatever 1.23;

then at least you get a prettier error message that doesn't confuse
users so much:

  $ perl5.10.1
  Perl v5.12.0 required--this is only v5.10.1, stopped at line 1.

Paul "LeoNerd" Evans      |  |

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