young_stu has asked for the wisdom of the Perl Monks concerning the following question:
To see the failure, run the script and do the following:use warnings; use strict; use Tk; my $string = "foobarbaz"; my $mw = MainWindow->new; my $regexp_entry = $mw -> Entry() -> pack; my $go_button = $mw -> Button( -takefocus => 1, -text => "Match using what you typed!", -command => sub{ my $exp = $regexp_entry -> get(); print STDOUT "I'm looking for a match for $exp...\n"; $string =~ m/$exp/ ? print STDOUT "match!\n" : print STDOUT "N +o match!\n"; } )-> pack; my $used_stored_exp = $mw -> Button( -text => "Match with Stored Regexp!", -command => sub{ my $exp = qr/foo/; print STDOUT "I'm looking for a match for $exp...\n"; $string =~ m/$exp/ ? print STDOUT "match!\n" : print STDOUT "N +o match!\n"; } )-> pack; $regexp_entry -> focus; MainLoop;
into the entry widget, press the "Match using what you typed!" button, and watch STDOUT.qr/foo/
into the entry widget.(?-xism:foo)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing qr//'d regexp via Perl/Tk Entry widget
by crashtest (Curate) on Jun 23, 2005 at 22:29 UTC | |
by young_stu (Beadle) on Jun 23, 2005 at 23:13 UTC | |
by crashtest (Curate) on Jun 23, 2005 at 23:42 UTC | |
by young_stu (Beadle) on Jun 24, 2005 at 00:23 UTC | |
|
Re: passing qr//'d regexp via Perl/Tk Entry widget
by injunjoel (Priest) on Jun 23, 2005 at 22:18 UTC |