eval { local $SIG{ALRM} = sub { $signal = 'alarm'; die 'alarm'; }; alarm(1); @a = ($input =~ /$regex/xg); alarm(0); }; if ($@ =~ /alarm/ ||$signal eq 'alarm') { $error = "regex match timed out"; print "$error\n"; die; }
Update: Regex example given by Hue-Bond sets off the alarm but the regex examples given by Ieronim and wfsp does not. does anyone know what that is the case?
In reply to Timeout alarm for regex by Otogi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |