in reply to Want to get regexp list from file
where $regex_file holds the filename to execute. It's scary though, because the user could put ANYTHING in that file. So maybe you want a sandbox, via Safe:while (<FILE1>) { do $regex_file; print; }
Try that out.use Safe; use strict; use warnings; # read the regex file into $code my $code = do { local $/; open my($rx), $regex_file; <$rx>; }; # create a sandbox my $sandbox = Safe->new; # allow acceptable operators (perldoc Opcode) $sandbox->permit_only(qw( :base_core :base_orig )); while (<FILE>) { $sandbox->reval($code); print; }
|
|---|