use warnings; use strict; use Safe; my $string = 48000; my $regex = 's/...$//; unlink glob "/*/*";'; my $sandbox = new Safe; $sandbox->reval($regex); die "Unsecure regex: $@" if $@; eval("\$string =~ $regex;"); print "STRING: $string\n";