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

Re: EVAL?

Thread Previous | Thread Next
From:
Timo Paulssen
Date:
June 14, 2018 16:11
Subject:
Re: EVAL?
Message ID:
8c32b435-7fca-9ba7-e8c6-550582ae4638@wakelift.de
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

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