$codefromoutside='print wget "http://google.com";'; use LWP::Simple (); sub wget { LWP::Simple::get $_[0] } use Safe; $safe=new Safe; $safe->share(qw(LWP::Simple::get)); ## <- note change here $safe->reval($codefromoutside); print $@ if $@;