develooper Front page | perl.perl5.porters | Postings from September 2022

Re: module loading built-in

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
September 17, 2022 10:57
Subject:
Re: module loading built-in
Message ID:
20220917115704.16dce1d5@shy.leonerd.org.uk
On Sat, 17 Sep 2022 03:53:53 -0700
Darren Duncan <darren@darrenduncan.net> wrote:

> > I don't see what a builtin would add.
> > 
> > eval "use $module; 1"
> > 
> > Works fine.  
> 
> Why?  Its because having to use string eval for something so simple
> and basic is a TERRIBLE design, a huge code smell.  The proposal of a
> proper basic runtime-defined load that DOESN'T use string eval is
> sorely needed.  This is insecure and error prone like SQL injection
> from straight interpolation of variables into the raw source when it
> should just be a plain value or argument. 

+1. (Well, +2 if I could ;) )

Plus also Yves' code didnt' handle errors; you forgot to

  eval "use $module; 1" or die $@;

and already we see why

  builtin::load $module;

would be much nicer.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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