Popcorn Dave has asked for the wisdom of the Perl Monks concerning the following question:
I am close to finishing a Perl/Tk program to test regexes that lets the user enter a regex, the text they want to fiddle with, then prints out the result. Regex options are handled via checkboxes so that they can mix and match to see what happens.
My problem is getting the user built regex to actually evaluate. I've tried using eval with {}, "", '' and nothing at all, but to no avail.
Here's the code I'm playng with at present:
sub do_it{ $regex .= $options; my $blah = $user_text; eval{$user_text =~ $regex}; print "User text: $user_text\n"; }
The $options is built from the check boxes. But $user_text is never getting changed- e.g. $regex=s/e/y/ $user_text=there - still sends $user_text back as there, not thyre.
Can someone please throw some light on this and point me in a direction to solve this?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question on evaulating a user built regex
by erikharrison (Deacon) on Apr 22, 2002 at 15:57 UTC | |
by Popcorn Dave (Abbot) on Apr 22, 2002 at 16:05 UTC | |
by BrentDax (Hermit) on Apr 22, 2002 at 21:21 UTC | |
|
Re: Question on evaulating a user built regex
by perlplexer (Hermit) on Apr 22, 2002 at 16:33 UTC | |
|
Re: Question on evaulating a user built regex
by Stegalex (Chaplain) on Apr 22, 2002 at 19:57 UTC | |
|
Re: Question on evaluating a user built regex
by Sweeper (Pilgrim) on Apr 23, 2002 at 05:50 UTC | |
by perlplexer (Hermit) on Apr 23, 2002 at 13:06 UTC |