in reply to Re^2: matching a regular expression
in thread matching a regular expression
That's not true. Without use re 'eval', it won't execute Perl code.
my $input = '(?{ print("Hello World!\\n") })'; print(qq{Without "use re 'eval';":\n}); eval { '' =~ /$input/; }; warn($@) if $@; print("\n"); print(qq{With "use re 'eval';":\n}); eval { use re 'eval'; '' =~ /$input/; }; warn("Died: $@") if $@;
outputs
Without "use re 'eval';": Died: Eval-group not allowed at runtime, use re 'eval' in regex m/(?{ +print("Hello World!\n") })/. With "use re 'eval';": Hello World!
On the other hand, some regexps take forever to execute. Some might even crash perl.
|
|---|