in reply to How to gracefully deal with a regex problem
Put eval { } around the part that dies and then check $@. If $@ is set, then you averted a nasty death and can refuse to put the value into the database.
Even more reliable is:
if( ! eval { ...; 1 } ) { warn "Invalid value ($@)..."; }
since pathelogical cases can set $@ even though the code succeeded.
Checking other responses, I notice \Q being suggested. Let me just add that if that works for you then you might want to consider using index() instead of a regex.
- tye (but my friends call me "Tye")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: How to gracefully deal with a regex problem
by michellem (Friar) on Mar 07, 2001 at 02:22 UTC | |
by tye (Sage) on Mar 07, 2001 at 02:32 UTC |