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

Re: Pre-RFC: Phaser Expressions

Thread Previous
From:
Ovid via perl5-porters
Date:
November 15, 2021 11:57
Subject:
Re: Pre-RFC: Phaser Expressions
Message ID:
1108686240.543978.1636977408347@mail.yahoo.com
> On Monday, 15 November 2021, 12:47:51 CET, Paul "LeoNerd" Evans  <leonerd@leonerd.org.uk> 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.

Best,
Ovid
-- 
IT consulting, training, specializing in Perl, databases, and agile development
http://www.allaroundtheworld.fr/. 

Buy my book! - http://bit.ly/beginning_perl

Thread Previous


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