Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: How to use Safe to compile anonymous subs

by rir (Vicar)
on Jul 30, 2008 at 20:02 UTC ( [id://701255]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to use Safe to compile anonymous subs
in thread How to use Safe to compile anonymous subs

What you want is probably:

my $code = 'sub { my $arg = shift; warn $arg; }';

Update: Since the above looks alot like your original post, here is more.

I've never used Safe but my doc's indicate that you need a namespace as the first arg to Safe->new.

use Safe; my $code = 'sub { my $arg = shift; warn $arg; }'; my $safe = Safe->new(); my $ssub = $safe->reval( $code) || die ; $ssub->( "hello$/" ); &$ssub( "hello$/" );

Be well,
rir

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://701255]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found