develooper Front page | perl.perl5.porters | Postings from November 2021

Re: Pre-RFC: Phaser Expressions

Thread Previous
Ovid via perl5-porters
November 15, 2021 11:57
Re: Pre-RFC: Phaser Expressions
Message ID:
> On Monday, 15 November 2021, 12:47:51 CET, Paul "LeoNerd" Evans  <> wrote:
> TL;DR: Add `BEGIN expr...` syntax to hoist the evaluation time of an
>  expression into BEGIN time, without creating a new scope.

Yes, please! I get tired of doing the following:

    use Getopt::Long;
    my %opt_for;
    BEGIN {
        GetOptions( \%opt_for, ... );

I would love to simply do:

    use Getopt::Long;
    BEGIN GetOptions( \my %opt_for, ... );

In fact, grepping through a few codebases shows a number of places where we use BEGIN blocks with variables declared before them.

IT consulting, training, specializing in Perl, databases, and agile development 

Buy my book! -

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