develooper Front page | perl.perl6.users | Postings from June 2018

Re: EVAL?

Thread Previous | Thread Next
From:
ToddAndMargo
Date:
June 14, 2018 17:12
Subject:
Re: EVAL?
Message ID:
0f9bb229-a1d2-6d41-ed1d-c8e721e2e8d0@zoho.com
On 06/14/2018 09:11 AM, Timo Paulssen wrote:
> If it's literally just the name of a sub that you'll immediately invoke,
> you can side-step EVAL completely
> 
>      ::('&' ~ $RunSpecific)()
> 
> should do the trick.
> 
> ::("&foo") will give you the sub object, and putting () after it will
> immediately call it.
> 
> It will allow access to all subs, even from the core, so subs like "die"
> and "exit" are reachable, but it's less dangerous than accepting any
> random code. For one, it will only work with subs that don't take arguments.
> 
> HTH
>    - Timo
> 


Perfect!  Thank you!

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